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; MethodSymbol m = tree.sym;
tree.params = tree.params.prepend(ordParam).prepend(nameParam); tree.params = tree.params.prepend(ordParam).prepend(nameParam);
incrementParamTypeAnnoIndexes(m, 2);
m.extraParams = m.extraParams.prepend(ordParam.sym); m.extraParams = m.extraParams.prepend(ordParam.sym);
m.extraParams = m.extraParams.prepend(nameParam.sym); m.extraParams = m.extraParams.prepend(nameParam.sym);
@ -2667,17 +2666,6 @@ public class Lower extends TreeTranslator {
currentMethodSym = prevMethodSym; 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) { private void visitMethodDefInternal(JCMethodDecl tree) {
if (tree.name == names.init && if (tree.name == names.init &&
@ -2711,7 +2699,6 @@ public class Lower extends TreeTranslator {
tree.params = tree.params.appendList(fvdefs); tree.params = tree.params.appendList(fvdefs);
if (currentClass.hasOuterInstance()) { if (currentClass.hasOuterInstance()) {
tree.params = tree.params.prepend(otdef); tree.params = tree.params.prepend(otdef);
incrementParamTypeAnnoIndexes(m, 1);
} }
// If this is an initial constructor, i.e., it does not start with // 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, private void writeParamAnnotations(MethodSymbol m,
RetentionPolicy retention) { RetentionPolicy retention) {
databuf.appendByte(m.params.length() + m.extraParams.length()); databuf.appendByte(m.params.length());
writeParamAnnotations(m.extraParams, retention);
writeParamAnnotations(m.params, retention); writeParamAnnotations(m.params, retention);
} }

View File

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

View File

@ -44,15 +44,6 @@ public class SyntheticParameters extends ClassfileInspector {
null, null,
new ExpectedMethodTypeAnnotation[] { new ExpectedMethodTypeAnnotation[] {
(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 // Assert there is an annotation on the
// first parameter. // first parameter.
new ExpectedMethodTypeAnnotation.Builder( new ExpectedMethodTypeAnnotation.Builder(
@ -60,21 +51,7 @@ public class SyntheticParameters extends ClassfileInspector {
"A", "A",
TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER, TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
false, false,
1).setParameterIndex(1).build(), 1).setParameterIndex(0).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()
}, },
null); null);
private static final Expected Foo_expected = private static final Expected Foo_expected =
@ -89,26 +66,7 @@ public class SyntheticParameters extends ClassfileInspector {
"A", "A",
TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER, TypeAnnotation.TargetType.METHOD_FORMAL_PARAMETER,
false, false,
0).setParameterIndex(0).build(), 1).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()
},
null); null);
public static void main(String... args) throws Exception { 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 = "TA", type = METHOD_RETURN, genericLocation = {1, 0})
@TADescription(annotation = "TB", 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") @TestClass("%TEST_CLASS_NAME%$Inner")
public String innerClass() { public String innerClass() {
return "class %TEST_CLASS_NAME% { class Inner {" + 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 = "TB", type = METHOD_RETURN, genericLocation = {1, 0})
@TADescription(annotation = "TC", type = METHOD_RECEIVER) @TADescription(annotation = "TC", type = METHOD_RECEIVER)
@TADescription(annotation = "TD", type = METHOD_RETURN, genericLocation = {1, 0}) @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") @TestClass("%TEST_CLASS_NAME%$Inner")
public String innerClass2() { public String innerClass2() {
return "class %TEST_CLASS_NAME% { class Inner {" + 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 = "TC", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
@TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0}) @TADescription(annotation = "TD", type = METHOD_RECEIVER, genericLocation = {1, 0})
@TADescription(annotation = "TE", type = METHOD_RETURN, genericLocation = {1, 0, 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") @TestClass("Outer$Middle$Inner")
public String innerClass3() { public String innerClass3() {
return "class Outer { class Middle { class Inner {" + 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 = "RTAs", type = METHOD_RETURN, genericLocation = {1, 0})
@TADescription(annotation = "RTBs", 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") @TestClass("%TEST_CLASS_NAME%$Inner")
public String innerClassRepeatableAnnotation() { public String innerClassRepeatableAnnotation() {
return "class %TEST_CLASS_NAME% { class Inner {" + 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 = "RTBs", type = METHOD_RETURN, genericLocation = {1, 0})
@TADescription(annotation = "RTCs", type = METHOD_RECEIVER) @TADescription(annotation = "RTCs", type = METHOD_RECEIVER)
@TADescription(annotation = "RTDs", type = METHOD_RETURN, genericLocation = {1, 0}) @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") @TestClass("%TEST_CLASS_NAME%$Inner")
public String innerClassRepeatableAnnotation2() { public String innerClassRepeatableAnnotation2() {
return "class %TEST_CLASS_NAME% { class Inner {" + 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 = "RTCs", type = METHOD_RETURN, genericLocation = {1, 0, 1, 0})
@TADescription(annotation = "RTDs", type = METHOD_RECEIVER, genericLocation = {1, 0}) @TADescription(annotation = "RTDs", type = METHOD_RECEIVER, genericLocation = {1, 0})
@TADescription(annotation = "RTEs", type = METHOD_RETURN, genericLocation = {1, 0, 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") @TestClass("Outer$Middle$Inner")
public String innerClassRepatableAnnotation3() { public String innerClassRepatableAnnotation3() {
return "class Outer { class Middle { class Inner {" + return "class Outer { class Middle { class Inner {" +