Unsupported Java 8 syntax
jejung opened this issue · comments
The following code fails with IllegalArgumentException:
public class Main {
public static <T> T[] producer(T... ts){
return ts;
}
public static <T> void consumer(Supplier<? extends T> objs){
}
public static void main(String[] args) throws IOException {
consumer(Main::producer);
new Indexer().index(Main.class.getClassLoader().getResourceAsStream("com/test/Main.class"));
}
}
The full stack trace is:
Exception in thread "main" java.lang.IllegalArgumentException: Expected character '^' at position 2
at org.jboss.jandex.GenericSignatureParser.expect(GenericSignatureParser.java:262)
at org.jboss.jandex.GenericSignatureParser.parseMethodSignature(GenericSignatureParser.java:298)
at org.jboss.jandex.Indexer.parseMethodSignature(Indexer.java:971)
at org.jboss.jandex.Indexer.applySignatures(Indexer.java:958)
at org.jboss.jandex.Indexer.index(Indexer.java:1449)
at com.test.Main.main(Main.java:29)
Here is a simple test project, hope this helps.
Interesting, what java compiler and version are you using?
The reason I ask is that your example seems to contain a class file that violates the VM spec. Your not supposed to be able to return a type argument, so it looks like a compiler bug. I'm trying to figure out if I need special handling if its a widespread issue, or if its only a specific compiler version with the problem.
private static ? extends java.lang.Object[] lambda$0();
descriptor: ()[Ljava/lang/Object;
flags: ACC_PRIVATE, ACC_STATIC, ACC_SYNTHETIC
Signature: #64 // ()+[Ljava/lang/Object;
Code:
stack=1, locals=0, args_size=0
0: iconst_0
1: anewarray #3 // class java/lang/Object
4: invokestatic #65 // Method producer:([Ljava/lang/Object;)[Ljava/lang/Object;
7: areturn
LocalVariableTable:
Start Length Slot Name Signature
I was compiling and running from eclipse, I tried to reproduce the problem out of eclipse but without success, so I think the problem may be with the eclipse compiler, can you confirm it?
Eclipse details:
Eclipse Java EE IDE for Web Developers.
Version: Neon Release (4.6.0)
Build id: 20160613-1800
Hi, I have the same issue. Also inside the Eclipse
Caused by: java.lang.IllegalArgumentException: Expected character '^' at position 2
at org.jboss.jandex.GenericSignatureParser.expect(GenericSignatureParser.java:262)
at org.jboss.jandex.GenericSignatureParser.parseMethodSignature(GenericSignatureParser.java:298)
at org.jboss.jandex.Indexer.parseMethodSignature(Indexer.java:1424)
at org.jboss.jandex.Indexer.applySignatures(Indexer.java:1411)
at org.jboss.jandex.Indexer.index(Indexer.java:1968)
at io.quarkus.deployment.steps.ApplicationIndexBuildStep$1.visitFile(ApplicationIndexBuildStep.java:38)
at io.quarkus.deployment.steps.ApplicationIndexBuildStep$1.visitFile(ApplicationIndexBuildStep.java:27)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2811)
at java.base/java.nio.file.Files.walkFileTree(Files.java:2882)
at io.quarkus.deployment.steps.ApplicationIndexBuildStep.build(ApplicationIndexBuildStep.java:27)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
at java.base/java.lang.Thread.run(Thread.java:833)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Is there some workaround for it?
Signature is ()+Lone/util/streamex/StreamEx<Lme/snowdrop/istio/api/networking/v1beta1/Server;>;
Same problem for me.
Please provide actionable information. I take bytecode parsing issues very seriously, but I need an actual reproducer. A Java (or Kotlin, or Scala, or Groovy, or whatever) source code is enough, as is a JAR file on Maven Central or similar.
First it's in Eclipse, I don't have any problem when compiling the code with javac.
I identified the exact line on my code that produces the "bug". Now I'm trying to make a small sample snippet and I will open a bug in Eclipse JDT.
The entire Jandex test suite runs with JDT on each pull request (or it should, at least :-) ). If there's a way to reproduce the problem with a small piece of Java source code, even if javac works just fine, I'd love to add it to the Jandex test suite. Thanks for your work on the reproducer!
I did managed to reproduce it with Eclipse JDT, you can see a sample code in eclipse-jdt/eclipse.jdt.core#756
Thank you! I managed to simplify your reproducer a little bit more (see the JDT issue) and I can add a test to the Jandex test suite for this.