Stop emitting Deprecated attributes
These have been obsolete since 1.5, and implementing them properly would
require parsing @deprecated javadoc tags.
MOE_MIGRATED_REVID=139261687
diff --git a/java/com/google/turbine/bytecode/Attribute.java b/java/com/google/turbine/bytecode/Attribute.java
index 78a5c9b..3f67fd8 100644
--- a/java/com/google/turbine/bytecode/Attribute.java
+++ b/java/com/google/turbine/bytecode/Attribute.java
@@ -35,7 +35,6 @@
ANNOTATION_DEFAULT("AnnotationDefault"),
RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS("RuntimeVisibleParameterAnnotations"),
RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS("RuntimeInvisibleParameterAnnotations"),
- DEPRECATED("Deprecated"),
RUNTIME_VISIBLE_TYPE_ANNOTATIONS("RuntimeVisibleTypeAnnotations"),
RUNTIME_INVISIBLE_TYPE_ANNOTATIONS("RuntimeInvisibleTypeAnnotations");
@@ -217,15 +216,6 @@
}
}
- /** A JVMS §4.7.15 Deprecated attribute. */
- Attribute DEPRECATED =
- new Attribute() {
- @Override
- public Kind kind() {
- return Kind.DEPRECATED;
- }
- };
-
interface TypeAnnotations extends Attribute {
ImmutableList<TypeAnnotationInfo> annotations();
}
diff --git a/java/com/google/turbine/bytecode/AttributeWriter.java b/java/com/google/turbine/bytecode/AttributeWriter.java
index 2d18ea5..9bf47fa 100644
--- a/java/com/google/turbine/bytecode/AttributeWriter.java
+++ b/java/com/google/turbine/bytecode/AttributeWriter.java
@@ -66,9 +66,6 @@
case RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS:
writeParameterAnnotations((Attribute.ParameterAnnotations) attribute);
break;
- case DEPRECATED:
- writeDeprecated(attribute);
- break;
case RUNTIME_INVISIBLE_TYPE_ANNOTATIONS:
case RUNTIME_VISIBLE_TYPE_ANNOTATIONS:
writeTypeAnnotation((Attribute.TypeAnnotations) attribute);
@@ -172,11 +169,6 @@
output.write(data);
}
- private void writeDeprecated(Attribute attribute) {
- output.writeShort(pool.utf8(attribute.kind().signature()));
- output.writeInt(0);
- }
-
private void writeTypeAnnotation(TypeAnnotations attribute) {
output.writeShort(pool.utf8(attribute.kind().signature()));
ByteArrayDataOutput tmp = ByteStreams.newDataOutput();
diff --git a/java/com/google/turbine/bytecode/LowerAttributes.java b/java/com/google/turbine/bytecode/LowerAttributes.java
index 1f7dc4a..d895f4f 100644
--- a/java/com/google/turbine/bytecode/LowerAttributes.java
+++ b/java/com/google/turbine/bytecode/LowerAttributes.java
@@ -80,9 +80,6 @@
List<AnnotationInfo> visible = new ArrayList<>();
List<AnnotationInfo> invisible = new ArrayList<>();
for (AnnotationInfo annotation : annotations) {
- if (annotation.typeName().equals("Ljava/lang/Deprecated;")) {
- attributes.add(Attribute.DEPRECATED);
- }
(annotation.isRuntimeVisible() ? visible : invisible).add(annotation);
}
if (!visible.isEmpty()) {
diff --git a/javatests/com/google/turbine/lower/IntegrationTestSupport.java b/javatests/com/google/turbine/lower/IntegrationTestSupport.java
index 64a9456..0c2d5b5 100644
--- a/javatests/com/google/turbine/lower/IntegrationTestSupport.java
+++ b/javatests/com/google/turbine/lower/IntegrationTestSupport.java
@@ -106,11 +106,18 @@
removeUnusedInnerClassAttributes(infos, n);
makeEnumsFinal(n);
sortMembersAndAttributes(n);
+ undeprecate(n);
}
return toByteCode(classes);
}
+ private static void undeprecate(ClassNode n) {
+ n.access &= ~Opcodes.ACC_DEPRECATED;
+ n.methods.forEach(m -> m.access &= ~Opcodes.ACC_DEPRECATED);
+ n.fields.forEach(f -> f.access &= ~Opcodes.ACC_DEPRECATED);
+ }
+
private static void makeEnumsFinal(ClassNode n) {
n.innerClasses.forEach(
x -> {
diff --git a/javatests/com/google/turbine/lower/LowerIntegrationTest.java b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
index d9d9cf0..8d30eca 100644
--- a/javatests/com/google/turbine/lower/LowerIntegrationTest.java
+++ b/javatests/com/google/turbine/lower/LowerIntegrationTest.java
@@ -269,6 +269,7 @@
"const_octal_underscore.test",
"const_boxed.test",
"interface_member_public.test",
+ "javadoc_deprecated.test",
};
List<Object[]> tests =
ImmutableList.copyOf(testCases).stream().map(x -> new Object[] {x}).collect(toList());
diff --git a/javatests/com/google/turbine/lower/testdata/javadoc_deprecated.test b/javatests/com/google/turbine/lower/testdata/javadoc_deprecated.test
new file mode 100644
index 0000000..572d561
--- /dev/null
+++ b/javatests/com/google/turbine/lower/testdata/javadoc_deprecated.test
@@ -0,0 +1,10 @@
+=== Test.java ===
+/** @deprecated */
+class Test {
+ /** @deprecated */
+ class Inner {}
+ /** @deprecated */
+ int x;
+ /** @deprecated */
+ void f() {}
+}