aboutsummaryrefslogtreecommitdiff
path: root/java/com
diff options
context:
space:
mode:
authorcushon <cushon@google.com>2016-11-28 17:33:22 -0800
committerLiam Miller-Cushon <cushon@google.com>2016-11-30 15:54:54 -0800
commit9278ff215c8a8c45c054ca71599df4cdff738666 (patch)
tree8709fd6671b366906ad532daeed574750183be1c /java/com
parent2f04f223f09954fcb385d7fa7b09fdbf667051bc (diff)
downloadturbine-9278ff215c8a8c45c054ca71599df4cdff738666.tar.gz
Resume emitting deprecated attributes
46527d994f4cd68a857a907abebe69559baf57eb was a mistake: javac only emits warnings if the attribute is present, the annotation is not sufficient. This doesn't change the decision to ignore @deprecated javadoc tags. MOE_MIGRATED_REVID=140423585
Diffstat (limited to 'java/com')
-rw-r--r--java/com/google/turbine/bytecode/Attribute.java10
-rw-r--r--java/com/google/turbine/bytecode/AttributeWriter.java8
-rw-r--r--java/com/google/turbine/bytecode/LowerAttributes.java3
3 files changed, 21 insertions, 0 deletions
diff --git a/java/com/google/turbine/bytecode/Attribute.java b/java/com/google/turbine/bytecode/Attribute.java
index 60bf6c4..0700744 100644
--- a/java/com/google/turbine/bytecode/Attribute.java
+++ b/java/com/google/turbine/bytecode/Attribute.java
@@ -36,6 +36,7 @@ interface Attribute {
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"),
METHOD_PARAMETERS("MethodParameters");
@@ -218,6 +219,15 @@ interface Attribute {
}
}
+ /** 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 cb8cf8a..4eece56 100644
--- a/java/com/google/turbine/bytecode/AttributeWriter.java
+++ b/java/com/google/turbine/bytecode/AttributeWriter.java
@@ -68,6 +68,9 @@ public class AttributeWriter {
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);
@@ -174,6 +177,11 @@ public class AttributeWriter {
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 bd18eb1..1752456 100644
--- a/java/com/google/turbine/bytecode/LowerAttributes.java
+++ b/java/com/google/turbine/bytecode/LowerAttributes.java
@@ -84,6 +84,9 @@ public class LowerAttributes {
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()) {