JDK-8193302 : Javac AssertionError: typeSig ERROR on usage of @Generated
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9,9.0.1,10
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: x86_64
  • Submitted: 2017-12-08
  • Updated: 2018-06-30
  • Resolved: 2018-06-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11
11 b19Fixed
Related Reports
CSR :  
Sub Tasks
JDK-8204542 :  
Description
FULL PRODUCT VERSION :
java version "10-ea"
Java(TM) SE Runtime Environment (build 10-ea+35)
Java HotSpot(TM) 64-Bit Server VM (build 10-ea+35, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
javac compile this java file:

import javax.annotation.*;
public class test
{
	@Generated(value={ "test" })
	public static void main(String[] args)
	{
	}
}

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
use javac to compile a program. Will compile on jdk-8, but not on jdk-9 or jdk-10

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
no crash on compile
ACTUAL -
crash on compile

ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (10-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: typeSig ERROR
        at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5165)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.assembleSig(ClassWriter.java:291)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.typeSig(ClassWriter.java:334)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeCompoundAttribute(ClassWriter.java:858)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeJavaAnnotations(ClassWriter.java:726)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:593)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1182)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1653)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1761)
        at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1679)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:749)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1627)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1595)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:965)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:306)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.annotation.*;
public class test
{
	@Generated(value={ "test" })
	public static void main(String[] args)
	{
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Do not use @Generated(value={ "test" })


Comments
From private communication with Jan: // -- In Java 8, it was AFAIK enough if the package named in import-on-demand had a sub-package, i.e.: import java.*; //was OK AFAIK So the code was written to e.g. accept javax.annotation if javax.annotation.processing is visible. But, looking at the final 9 spec, the package named in import-on-demand must be uniquely visible, which means that: import javax.annotation.*; should indeed produce an error (i.e. the suppressError parameter to lookupInvisibleSymbol is not needed at all). This will also probably require a tweak in Check.checkImportedPackagesObservable. It may also need to be source-level dependent (for that the behvior for --source 8 is unchanged). Please note that changing this is likely to break something (like tests), so I'd suggest to do a Mach 5 build on all platforms. I can look at this if you prefer. // -----
17-01-2018

Probably originates from JDK-8169197, change to com.sun.tools.javac.comp.Resolve#lookupPackage passes suppress error to lookupInvisibleSymbol
16-01-2018

If the * import is changed to import the specific type, I do see an error and no crash. /home/srikanth/tmp/X.java:1: error: package javax.annotation is not visible import javax.annotation.Generated; ^ (package javax.annotation is declared in module java.xml.ws.annotation, which is not in the module graph) 1 error
16-01-2018

See JDK-8152931, I believe SE JDK core libraries do not contain this annotation anymore. So the program should actually fail to compile beginning JDK9, as it does with Java 9 enabled Eclipse. But the compiler should reject this program and not go into code generation and crash and burn. Investigating why.
16-01-2018

@Fairoz, No, this is not introduced by JDK-8171322. If I back out the one line change made for that fix, I still get a crash. I will look into it.
16-01-2018

This is an issue, code works fine in 8 and fails in 9 and 10. Below are the results 8u162 - Pass 9 ea b153 - Pass (Compilation failure but no assert error) 9 ea b154 - Fail (Assert error) 10 ea b35 - Fail == -sh-4.2$ /scratch/fairoz/JAVA/jdk10/jdk-10-ea+33/bin/javac test.java An exception has occurred in the compiler (10-ea). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you. java.lang.AssertionError: typeSig ERROR at jdk.compiler/com.sun.tools.javac.code.Types$SignatureGenerator.assembleSig(Types.java:5108) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter$CWSignatureGenerator.assembleSig(ClassWriter.java:291) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.typeSig(ClassWriter.java:334) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeCompoundAttribute(ClassWriter.java:858) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeJavaAnnotations(ClassWriter.java:726) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMemberAttrs(ClassWriter.java:593) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMethod(ClassWriter.java:1182) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeMethods(ClassWriter.java:1653) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1761) at jdk.compiler/com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1679) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:748) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1626) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1594) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:964) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:306) at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165) at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57) at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
11-12-2017