Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 444311

Summary: "Inconsistent classfile encountered" with bounded type parameter that refers to inner class
Product: [Eclipse Project] JDT Reporter: Ben Hamilton <foxden>
Component: CoreAssignee: Sasikanth Bharadwaj <sasikanth.bharadwaj>
Status: CLOSED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: abuehler, srikanth_sankaran
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard: stalebug
Attachments:
Description Flags
Repro case for bug. Unzip and run "build.sh". none

Description Ben Hamilton CLA 2014-09-16 18:54:40 EDT
Created attachment 247137 [details]
Repro case for bug. Unzip and run "build.sh".

The Eclipse compiler generates invalid bytecode for interfaces containing methods with bounded type parameters that refer to inner classes.

To reproduce (I used Eclipse 4.4; it also reproduced in 4.3), please unzip the attached zip file (ecj-repro.zip, which contains org.eclipse.jdt.core-3.10.0.v20140604-1726.jar) and run:

% build.sh

It will compile with the system javac, verify the bytecode is valid, then try to repeat the same with the Eclipse compiler.

You can confirm the Eclipse compiler's generated bytecode is invalid with javap (an invalid type signature for TestInterface.doBar()):

% java -jar jar/org.eclipse.jdt.core-3.10.0.v20140604-1726.jar -1.6 Test*.java
% javap -c TestInterface
                                                      
Compiled from "TestInterface.java"
public interface TestInterface<T> {
  public abstract void doFoo();
Error:  A serious internal error has occurred: java.lang.IllegalStateException: <C:LTestClass<TT;>;>(TC.InnerClass<TT;!>!;)V
Please file a bug report, and include the following information:
java.lang.IllegalStateException: <C:LTestClass<TT;>;>(TC.InnerClass<TT;!>!;)V
	at com.sun.tools.classfile.Signature.parseTypeSignature(Signature.java:180)
	at com.sun.tools.classfile.Signature.parseTypeSignatures(Signature.java:188)
	at com.sun.tools.classfile.Signature.parse(Signature.java:93)
	at com.sun.tools.classfile.Signature.getType(Signature.java:48)
	at com.sun.tools.javap.ClassWriter.writeMethod(ClassWriter.java:427)
	at com.sun.tools.javap.ClassWriter.writeMethods(ClassWriter.java:402)
	at com.sun.tools.javap.ClassWriter.write(ClassWriter.java:219)
	at com.sun.tools.javap.JavapTask.write(JavapTask.java:810)
	at com.sun.tools.javap.JavapTask.writeClass(JavapTask.java:633)
	at com.sun.tools.javap.JavapTask.run(JavapTask.java:589)
	at com.sun.tools.javap.JavapTask.run(JavapTask.java:453)
	at com.sun.tools.javap.Main.main(Main.java:46)
Comment 1 Ben Hamilton CLA 2014-09-16 19:06:47 EDT
Forgot to mention, the output I get on my system with Eclipse 4.4 is:

% ./build.sh
Building with javac... done.
Verifying bytecode... done.
Building with Eclipse compiler... ----------
1. ERROR in UnrelatedClass.java (at line 1)
	public class UnrelatedClass {
	^
Inconsistent classfile encountered: The undefined type parameter C.InnerClass is referenced from within TestInterface<T>
----------
1 problem (1 error)
Comment 2 Srikanth Sankaran CLA 2014-09-16 19:08:46 EDT
Reproduced on head. As called out by reporter, not a recent regression.

Simply paste the 4 files from the zip into explorer to reproduce.
Comment 3 Eclipse Genie CLA 2020-01-03 19:00:13 EST
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.