8066725: javac produces classfiles it cannot read

Revert behavioral changes from 8029012 and 8065132

Reviewed-by: jfranck
This commit is contained in:
Eric McCorkle 2015-02-13 17:00:45 -05:00
parent 7081b471c4
commit b014a7728f
5 changed files with 13 additions and 130 deletions

View File

@ -2644,7 +2644,6 @@ public class Lower extends TreeTranslator {
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 @@ public class Lower extends TreeTranslator {
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 @@ public class Lower extends TreeTranslator {
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

View File

@ -656,8 +656,7 @@ public class ClassWriter extends ClassFile {
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);
}

View File

@ -46,20 +46,11 @@ public class SyntheticParameters extends ClassfileInspector {
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 @@ public class SyntheticParameters extends ClassfileInspector {
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,56 +92,20 @@ public class SyntheticParameters extends ClassfileInspector {
null,
new ExpectedParameterAnnotation[] {
(ExpectedParameterAnnotation)
// Assert there is no annotation on the
// $enum$name 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),
(ExpectedParameterAnnotation)
// Assert there is an annotation on the
// first parameter.
new ExpectedParameterAnnotation(
"<init>",
2,
0,
"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,
0,
"B",
false,
1)

View File

@ -44,15 +44,6 @@ public class SyntheticParameters extends ClassfileInspector {
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 @@ public class SyntheticParameters extends ClassfileInspector {
"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 @@ public class SyntheticParameters extends ClassfileInspector {
"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 {

View File

@ -43,7 +43,7 @@ public class Constructors {
@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 @@ public class Constructors {
@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 @@ public class Constructors {
@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 @@ public class Constructors {
@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 @@ public class Constructors {
@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 @@ public class Constructors {
@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 {" +