8066725: javac produces classfiles it cannot read
authoremc
Fri, 13 Feb 2015 17:00:45 -0500
changeset 29050 76df9080086c
parent 28895 6efe265424e3
child 29051 7244db2ab176
8066725: javac produces classfiles it cannot read Summary: Revert behavioral changes from 8029012 and 8065132 Reviewed-by: jfranck
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java
langtools/test/tools/javac/annotations/SyntheticParameters.java
langtools/test/tools/javac/annotations/typeAnnotations/classfile/SyntheticParameters.java
langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Jul 05 20:19:45 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Feb 13 17:00:45 2015 -0500
@@ -2644,7 +2644,6 @@
 
             MethodSymbol m = tree.sym;
             tree.params = tree.params.prepend(ordParam).prepend(nameParam);
-            incrementParamTypeAnnoIndexes(m, 2);
 
             m.extraParams = m.extraParams.prepend(ordParam.sym);
             m.extraParams = m.extraParams.prepend(nameParam.sym);
@@ -2667,17 +2666,6 @@
             currentMethodSym = prevMethodSym;
         }
     }
-    //where
-    private void incrementParamTypeAnnoIndexes(MethodSymbol m,
-                                               int amount) {
-        for (final Attribute.TypeCompound anno : m.getRawTypeAttributes()) {
-            // Increment the parameter_index of any existing formal
-            // parameter annotations.
-            if (anno.position.type == TargetType.METHOD_FORMAL_PARAMETER) {
-                anno.position.parameter_index += amount;
-            }
-        }
-    }
 
     private void visitMethodDefInternal(JCMethodDecl tree) {
         if (tree.name == names.init &&
@@ -2711,7 +2699,6 @@
             tree.params = tree.params.appendList(fvdefs);
             if (currentClass.hasOuterInstance()) {
                 tree.params = tree.params.prepend(otdef);
-                incrementParamTypeAnnoIndexes(m, 1);
             }
 
             // If this is an initial constructor, i.e., it does not start with
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Jul 05 20:19:45 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Feb 13 17:00:45 2015 -0500
@@ -656,8 +656,7 @@
 
     private void writeParamAnnotations(MethodSymbol m,
                                        RetentionPolicy retention) {
-        databuf.appendByte(m.params.length() + m.extraParams.length());
-        writeParamAnnotations(m.extraParams, retention);
+        databuf.appendByte(m.params.length());
         writeParamAnnotations(m.params, retention);
     }
 
--- a/langtools/test/tools/javac/annotations/SyntheticParameters.java	Wed Jul 05 20:19:45 2017 +0200
+++ b/langtools/test/tools/javac/annotations/SyntheticParameters.java	Fri Feb 13 17:00:45 2015 -0500
@@ -46,20 +46,11 @@
                      null,
                      new ExpectedParameterAnnotation[] {
                          (ExpectedParameterAnnotation)
-                         // Assert there is no annotation on the
-                         // this$0 parameter.
-                         new ExpectedParameterAnnotation(
-                             "<init>",
-                             0,
-                             "A",
-                             true,
-                             0),
-                         (ExpectedParameterAnnotation)
                          // Assert there is an annotation on the
                          // first parameter.
                          new ExpectedParameterAnnotation(
                              "<init>",
-                             1,
+                             0,
                              "A",
                              true,
                              1),
@@ -71,27 +62,11 @@
                              true,
                              1),
                          (ExpectedParameterAnnotation)
-                         new ExpectedParameterAnnotation(
-                             "foo",
-                             1,
-                             "A",
-                             true,
-                             0),
-                         (ExpectedParameterAnnotation)
-                         // Assert there is no annotation on the
-                         // this$0 parameter.
-                         new ExpectedParameterAnnotation(
-                             "<init>",
-                             0,
-                             "B",
-                             false,
-                             0),
-                         (ExpectedParameterAnnotation)
                          // Assert there is an annotation on the
                          // first parameter.
                          new ExpectedParameterAnnotation(
                              "<init>",
-                             1,
+                             0,
                              "B",
                              false,
                              1),
@@ -117,58 +92,22 @@
                      null,
                      new ExpectedParameterAnnotation[] {
                          (ExpectedParameterAnnotation)
-                         // Assert there is no annotation on the
-                         // $enum$name parameter.
+                         // Assert there is an annotation on the
+                         // first parameter.
                          new ExpectedParameterAnnotation(
                              "<init>",
                              0,
                              "A",
                              true,
-                             0),
-                         (ExpectedParameterAnnotation)
-                         // Assert there is no annotation on the
-                         // $enum$ordinal parameter.
-                         new ExpectedParameterAnnotation(
-                             "<init>",
-                             1,
-                             "A",
-                             true,
-                             0),
+                             1),
                          (ExpectedParameterAnnotation)
                          // Assert there is an annotation on the
                          // first parameter.
                          new ExpectedParameterAnnotation(
                              "<init>",
-                             2,
-                             "A",
-                             true,
-                             1),
-                         (ExpectedParameterAnnotation)
-                         // Assert there is no annotation on the
-                         // $enum$name parameter.
-                         new ExpectedParameterAnnotation(
-                             "<init>",
                              0,
                              "B",
                              false,
-                             0),
-                         (ExpectedParameterAnnotation)
-                         // Assert there is no annotation on the
-                         // $enum$ordinal parameter.
-                         new ExpectedParameterAnnotation(
-                             "<init>",
-                             1,
-                             "B",
-                             false,
-                             0),
-                         (ExpectedParameterAnnotation)
-                         // Assert there is an annotation on the
-                         // first parameter.
-                         new ExpectedParameterAnnotation(
-                             "<init>",
-                             2,
-                             "B",
-                             false,
                              1)
                      },
                      null);
--- a/langtools/test/tools/javac/annotations/typeAnnotations/classfile/SyntheticParameters.java	Wed Jul 05 20:19:45 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/classfile/SyntheticParameters.java	Fri Feb 13 17:00:45 2015 -0500
@@ -44,15 +44,6 @@
                      null,
                      new ExpectedMethodTypeAnnotation[] {
                          (ExpectedMethodTypeAnnotation)
-                         // Assert there is no annotation on the
-                         // this$0 parameter.
-                         new ExpectedMethodTypeAnnotation.Builder(
-                             "<init>",
-                             "A",
-                             TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
-                             false,
-                             0).setParameterIndex(0).build(),
-                         (ExpectedMethodTypeAnnotation)
                          // Assert there is an annotation on the
                          // first parameter.
                          new ExpectedMethodTypeAnnotation.Builder(
@@ -60,21 +51,7 @@
                              "A",
                              TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
                              false,
-                             1).setParameterIndex(1).build(),
-                         (ExpectedMethodTypeAnnotation)
-                         new ExpectedMethodTypeAnnotation.Builder(
-                             "foo",
-                             "A",
-                             TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
-                             false,
-                             1).setParameterIndex(0).build(),
-                         (ExpectedMethodTypeAnnotation)
-                         new ExpectedMethodTypeAnnotation.Builder(
-                             "foo",
-                             "A",
-                             TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
-                             false,
-                             0).setParameterIndex(1).build()
+                             1).setParameterIndex(0).build()
                      },
                      null);
     private static final Expected Foo_expected =
@@ -89,26 +66,7 @@
                              "A",
                              TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
                              false,
-                             0).setParameterIndex(0).build(),
-                         (ExpectedMethodTypeAnnotation)
-                         // Assert there is no annotation on the
-                         // $enum$ordinal parameter.
-                         new ExpectedMethodTypeAnnotation.Builder(
-                             "<init>",
-                             "A",
-                             TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
-                             false,
-                             0).setParameterIndex(1).build(),
-                         (ExpectedMethodTypeAnnotation)
-                         // Assert there is an annotation on the
-                         // first parameter.
-                         new ExpectedMethodTypeAnnotation.Builder(
-                             "<init>",
-                             "A",
-                             TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
-                             false,
-                             1).setParameterIndex(2).build()
-                     },
+                             1).setParameterIndex(0).build()                     },
                      null);
 
     public static void main(String... args) throws Exception {
--- a/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java	Wed Jul 05 20:19:45 2017 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/referenceinfos/Constructors.java	Fri Feb 13 17:00:45 2015 -0500
@@ -43,7 +43,7 @@
 
     @TADescription(annotation = "TA", type = METHOD_RETURN, genericLocation = {1, 0})
     @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0})
-    @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
+    @TADescription(annotation = "TC", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
     @TestClass("%TEST_CLASS_NAME%$Inner")
     public String innerClass() {
         return "class %TEST_CLASS_NAME% { class Inner {" +
@@ -56,7 +56,7 @@
     @TADescription(annotation = "TB", type = METHOD_RETURN, genericLocation = {1, 0})
     @TADescription(annotation = "TC", type = METHOD_RECEIVER)
     @TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0})
-    @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
+    @TADescription(annotation = "TE", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
     @TestClass("%TEST_CLASS_NAME%$Inner")
     public String innerClass2() {
         return "class %TEST_CLASS_NAME% { class Inner {" +
@@ -70,7 +70,7 @@
     @TADescription(annotation = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
     @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0})
     @TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
-    @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
+    @TADescription(annotation = "TF", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
     @TestClass("Outer$Middle$Inner")
     public String innerClass3() {
         return "class Outer { class Middle { class Inner {" +
@@ -89,7 +89,7 @@
 
     @TADescription(annotation = "RTAs", type = METHOD_RETURN, genericLocation = {1, 0})
     @TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0})
-    @TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
+    @TADescription(annotation = "RTCs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
     @TestClass("%TEST_CLASS_NAME%$Inner")
     public String innerClassRepeatableAnnotation() {
         return "class %TEST_CLASS_NAME% { class Inner {" +
@@ -102,7 +102,7 @@
     @TADescription(annotation = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0})
     @TADescription(annotation = "RTCs", type = METHOD_RECEIVER)
     @TADescription(annotation = "RTDs", type = METHOD_RETURN, genericLocation = {1, 0})
-    @TADescription(annotation = "RTEs", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
+    @TADescription(annotation = "RTEs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
     @TestClass("%TEST_CLASS_NAME%$Inner")
     public String innerClassRepeatableAnnotation2() {
         return "class %TEST_CLASS_NAME% { class Inner {" +
@@ -116,7 +116,7 @@
     @TADescription(annotation = "RTCs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
     @TADescription(annotation = "RTDs", type = METHOD_RECEIVER, genericLocation = {1, 0})
     @TADescription(annotation = "RTEs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
-    @TADescription(annotation = "RTFs", type = METHOD_FORMAL_PARAMETER, paramIndex = 1)
+    @TADescription(annotation = "RTFs", type = METHOD_FORMAL_PARAMETER, paramIndex = 0)
     @TestClass("Outer$Middle$Inner")
     public String innerClassRepatableAnnotation3() {
         return "class Outer { class Middle { class Inner {" +