Community
Participate
Working Groups
Take the following complete example: import java.util.function.Function; public class ArrFunctionCompositionTest { static class A {} static class B {} static class C {} public static void main(String[] args) { Function<? super A, ? extends B[]> aToBArr = a -> new B[] { new B() }; System.out.println(aToBArr.andThen(arr -> new C()).apply(new A())); } } It defines a function from A to an array of B, then composes it with another function from an array of bs to C, obtaining a function from A to C. At the end it applies the obtained function to some A and prints the resulting C. When running this example in Eclipse, I get an error with the following stack trace: Exception in thread "main" java.lang.ClassFormatError: Method "lambda$1" in class ArrFunctionCompositionTest has illegal signature "(L[LArrFunctionCompositionTest$B;;)LArrFunctionCompositionTest$C;" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) at java.net.URLClassLoader.access$100(URLClassLoader.java:74) at java.net.URLClassLoader$1.run(URLClassLoader.java:369) at java.net.URLClassLoader$1.run(URLClassLoader.java:363) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:362) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495) Whearas compiling and running the code with javac/java of JDK 8u192 works fine.
The problem seems to come from the signature computation. For the capture binding (capture#2-of ? extends ArrFunctionCompositionTest.B[]), we return a signature: L[LArrFunctionCompositionTest$B;; instead of [LArrFunctionCompositionTest$B; I made that hack: @Override public char[] signature() /* Ljava/lang/Object; */ { if (this.signature != null) return this.signature; char[] constantPoolName2 = constantPoolName(); if (constantPoolName2[0] == '[') { return this.signature = constantPoolName2; } return this.signature = CharOperation.concat('L', constantPoolName2, ';'); } in org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding and it passed the test. Of course this is a hack.
(In reply to Olivier Thomann from comment #1) > the test. Of course this is a hack. :) Does overriding signature() in CaptureBinding fix this? Or perhaps in TypeVariableBinding, which is the guy who delegates constantPoolName() to its bound?
Yes, I was thinking more something like this in org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding: @Override public char[] signature() /* Ljava/lang/Object; */ { if (this.signature != null) return this.signature; char[] temp = null; if (this.firstBound != null) { temp = this.firstBound.constantPoolName(); if (!this.firstBound.isArrayType()) { temp = CharOperation.concat('L', temp, ';'); } } else { temp = CharOperation.concat('L', this.superclass.constantPoolName(), ';'); } this.signature = temp; return temp; } This passes the given test case.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.
Seems fixed in master