JDK-8071444 : Annotation of argument of enum constructor causes failure of compilation
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: other
  • CPU: x86
  • Submitted: 2015-01-22
  • Updated: 2015-01-23
  • Resolved: 2015-01-23
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b46)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b46, mixed mode)

A DESCRIPTION OF THE PROBLEM :
For case:

$ cat A.java

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
public @interface A {
}

$ cat E.java
public enum E {
  V("");

  private E(@A String p) {
  }
}

$ cat ETest.java

public class ETest {
  E e;
}

Separate compilation of ETest.java fails:

$ javac A.java E.java && javac ETest.java
ETest.java:2: error: cannot access E
  E e;
  ^
  bad class file: ./E.class
    bad RuntimeInvisibleParameterAnnotations attribute: E(String)
    Please remove or make sure it appears in the correct subdirectory of the classpath.
1 error

Should be noted that no such problem, when compilation performed in a single step:

$ javac A.java E.java ETest.java && echo "OK"
OK


REGRESSION.  Last worked in version 7u71


REPRODUCIBILITY :
This bug can be reproduced always.


Comments
This compiles fine with JDK 9 b38 as well, but fails with JDK 9 b46.
23-01-2015

The bug is submitted by Evgeny Mandrikov from JaCoCo dev group On 1/22/2015 3:53 PM, Evgeny Mandrikov wrote: > Hi Rory, > During testing of JDK 9 EA b45 I stumbled on an error from compiler with a message like: > bad class file: /private/tmp/example/target/classes/org/example/E.class > bad RuntimeInvisibleParameterAnnotations attribute: E(java.lang.String) > Please remove or make sure it appears in the correct subdirectory of the classpath. > I'm not entirely sure, but seems that there is an issue in javac. I'm attaching minimalistic example of Maven project, which reproduces this issue. It builds successfully with JDK 7u71, but fails with JDK 9b45. > In the meantime I'll continue with testing.
23-01-2015

Please see JDK-8066725.
23-01-2015