Unrecognized VM option ‘MaxPermSize=512m’ when running Zeppelin
If anyone still getting this renaming MaxPermSize to MaxMetaspaceSize fixed the issue on my part, migrated from gradle7.2 to gradle8 with jdk11 previously, now on jdk17
If anyone still getting this renaming MaxPermSize to MaxMetaspaceSize fixed the issue on my part, migrated from gradle7.2 to gradle8 with jdk11 previously, now on jdk17
For the specific question of generating a reverse IntStream, try something like this: static IntStream revRange(int from, int to) { return IntStream.range(from, to) .map(i -> to – i + from – 1); } This avoids boxing and sorting. For the general question of how to reverse a stream of any type, I don’t know of … Read more
As noted in your question and in my comment, ZoneRulesProvider.getAvailableZoneIds() creates a new set of all the available time zones’ string representation (the keys of the static final ConcurrentMap<String, ZoneRulesProvider> ZONES) each time a time zone needs to be parsed.1 Fortunately, a ZoneRulesProvider is an abstract class which is designed to be subclassed. The method … Read more
Each one of the Date classes are for specific purposes: If you want to use your Date in an SQL/JDBC context, use the java.sql.Timestamp. java.util.Date is the old Java API, it is not thread safe, you can difficultly handle time zoning, and on the top of all, it is poorly designed: one simple uniformity is … Read more
static <A, B> Stream<Pair<A, B>> zip(Stream<A> as, Stream<B> bs) { Iterator<A> i=as.iterator(); return bs.filter(x->i.hasNext()).map(b->new Pair<>(i.next(), b)); } This does not offer parallel execution but neither did the original zip implementation. And as F. Böller has pointed out it doesn’t work if bs is infinite and as is not. For a solution which works for all … Read more
You use a one-argument Stream.reduce(accumulator) version that has the following signature: Optional<T> reduce(BinaryOperator<T> accumulator); The BinaryOperator<T> accumulator can only accept elements of type T, but you have: <? extends Consumer<? super T>> I propose you to use a three-argument version of the Stream.reduce(…) method instead: <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator … Read more
There doesn’t appear to be any straightforward way to sort a List in parallel in Java 8. I don’t think this is fundamentally difficult; it looks more like an oversight to me. The difficulty with a hypothetical Collections.parallelSort(list, cmp) is that the Collections implementation knows nothing about the list’s implementation or its internal organization. This … Read more
According to my profiler, the operation spends most of the time in the method Thread.holdsLock, which can be indeed a costly operation, which is called by Component.checkTreeLock which is called indirectly by Component.updateCursorImmediately. Generally, you can avoid costly visual updates when updating multiple components by calling getContentPane().setVisible(false); right before the operation and getContentPane().setVisible(true); right afterwards, … Read more
Let’s look at the relevant part of the Java Language Specification, 15.13. Method Reference Expressions. It lists the following ways to a create method reference: MethodReference: ExpressionName :: [TypeArguments] Identifier ReferenceType :: [TypeArguments] Identifier Primary :: [TypeArguments] Identifier super :: [TypeArguments] Identifier TypeName . super :: [TypeArguments] Identifier ClassType :: [TypeArguments] new ArrayType :: new … Read more
With inspiration from other answers I came up with the following (rough) class hierarchy that is similar to the cake pattern in Scala: interface UserRepository { String authenticate(String username, String password); } interface UserRepositoryComponent { UserRepository getUserRepository(); } interface UserServiceComponent extends UserRepositoryComponent { default UserService getUserService() { return new UserService(getUserRepository()); } } class UserService { … Read more