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

javac should not add MethodParameters attributes to v51 and earlier class files

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 11
    • None
    • tools
    • None
    • b01

      javac currently emits MethodParameters attributes if -parameters is enabled even when writing v51 and earlier class files. It reports a warning when subsequently reading those class files if -Xlint:classfile is enabled.

      original compiler-dev report:
      http://mail.openjdk.java.net/pipermail/compiler-dev/2016-November/010508.html

      The suggestion in the thread is to not emit the attributes when writing class file versions for which it is not appropriate.

      === X.java
      class X {
        void f(int a) {}
      }
      === Y.java
      class Y {
        X x;
      }
      ===

      Repro (using 9.0.1+11):

      $ javac -parameters -source 7 -target 7 X.java
      $ javac -Xlint:classfile -sourcepath : Y.java
      ./X.class: warning: [classfile] MethodParameters attribute introduced in version 52.0 class files is ignored in version 51.0 class files

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

              Created:
              Updated:
              Resolved: