[OPENDJ-6488] Non-obvious error message from setup when using outdated Java Created: 26/Jul/19 Updated: 08/Nov/19 Resolved: 02/Oct/19
|Fix Version/s:||Not applicable|
|Reporter:||Mark Craig||Assignee:||Jean-Noël Rouvignac|
Users would rather see something like "Java 8 is no longer supported. Upgrade to at least Java 11.0.3." Not "An unexpected error has been raised during setup: 'java.lang.StringBuilder'":
|Comment by Peter Major [X] (Inactive) [ 28/Jul/19 ]|
The actual underlying stacktrace is:
When DJ is compiled with JDK 11 to bytecode 8, and the generic Reject.ifNull method is being called (that was compiled by 8 to 8), looks like the JVM gets confused in terms of what the varargs array type should be. Both arguments implement Comparable, but with a different generic type, and it looks like that the automatic type inference for the generic method call goes sideways. A quick fix would be to make the ifNull call generic: Reject.<Object>ifNull(...); but finding all these possible issues would not be simple. Alternative solution would be to use Object... type instead of generics in Reject.ifNull, but that would be a potentially binary incompatible change, and it would reintroduce some unintentional compiler warnings.
Even when one gets past this one issue, there is another:
One way to fix these is:
|Comment by Jean-Noël Rouvignac [ 29/Jul/19 ]|
Many thanks for your help Peter.
The NoSuchMethodError is a classical issue of the return type of a method that changed to a contravariant return type. The return type for CharBuffer.flip() has changed to a more sub class of what it previously was. Compiling on JDK 11 uses the method overload with the more precise type which is Java-11 only. When running that code on Java 8, the JVM barfs because it cannot find this Java-11 only API.
At this point I agree it is better to wait for full compilation into Java 11 binaries and fully discard support for Java 8.
|Comment by Jean-Noël Rouvignac [ 02/Oct/19 ]|
Since this problem arises deep in the bowels of Java code (missing Java 11 methods that do not exist in Java 8 -> NoSuchMethodError), it is not obvious how we can deal with it properly.
As a consequence we are not going to fix this.
|Comment by Matthew Swift [ 07/Nov/19 ]|
Moved to closed state because the fixVersion has already been released.