Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8226216

parameter modifiers are not visible to javac plugins across compilation boundaries


    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: tbd
    • Component/s: tools
    • Labels:


      javac fails to read modifiers from the MethodParameters attribute in class files, which prevents plugins from accessing those modifiers across compilation boundaries. The modifiers are handled correctly if the same symbol is compiled from source in the compilation where the plugin runs.

      === ./plugin/module-info.java
      module p {
        requires transitive jdk.compiler;
        provides com.sun.source.util.Plugin with p.P;
      === ./plugin/p/P.java
      package p;

      import com.sun.source.util.JavacTask;
      import com.sun.source.util.Plugin;
      import com.sun.source.util.TaskEvent;
      import com.sun.source.util.TaskListener;

      import javax.lang.model.element.Element;
      import javax.lang.model.element.ExecutableElement;
      import javax.lang.model.element.TypeElement;
      import javax.lang.model.element.VariableElement;

      public class P implements Plugin {

        public String getName() {
          return "P";

        public void init(JavacTask javacTask, String... strings) {
              new TaskListener() {
                public void finished(TaskEvent e) {
                  if (e.getKind() != TaskEvent.Kind.ENTER) {
                  TypeElement b = javacTask.getElements().getTypeElement("B");
                  for (Element m : b.getEnclosedElements()) {
                    if (m instanceof ExecutableElement) {
                      for (VariableElement p : ((ExecutableElement) m).getParameters()) {
                        System.err.println(p.getSimpleName() + " " + p.getModifiers());

      === ./test/A.java
      class A {}
      === ./test/B.java
      class B {
        void f(final int x) {}

      $ javac $(find plugin -name '*.java')

      # the final modifier is observable on parameters in the current compilation

      $ javac --processor-module-path plugin -Xplugin:P -parameters test/A.java test/B.java
      x [final]
      x [final]

      # the final modifier is not observable on parameters loaded from class files

      $ javac --processor-module-path plugin -Xplugin:P -parameters -classpath test test/A.java
      x []


          Issue Links



              • Assignee:
                cushon Liam Miller-Cushon
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: