6893062: remove support for obsolete attributes
Reviewed-by: ksrini
This commit is contained in:
parent
53c56beacc
commit
65e203be59
@ -64,11 +64,6 @@ public abstract class Attribute {
|
||||
public static final String StackMapTable = "StackMapTable";
|
||||
public static final String Synthetic = "Synthetic";
|
||||
|
||||
// JSR 277/294
|
||||
public static final String Module = "Module";
|
||||
public static final String ModuleExportTable = "ModuleExportTable";
|
||||
public static final String ModuleMemberTable = "ModuleMemberTable";
|
||||
|
||||
public static class Factory {
|
||||
public Factory() {
|
||||
// defer init of standardAttributeClasses until after options set up
|
||||
@ -78,10 +73,6 @@ public abstract class Attribute {
|
||||
this.compat = compat;
|
||||
}
|
||||
|
||||
public void setJSR277(boolean jsr277) {
|
||||
this.jsr277 = jsr277;
|
||||
}
|
||||
|
||||
public Attribute createAttribute(ClassReader cr, int name_index, byte[] data)
|
||||
throws IOException {
|
||||
if (standardAttributes == null)
|
||||
@ -121,12 +112,6 @@ public abstract class Attribute {
|
||||
standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class);
|
||||
standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class);
|
||||
|
||||
if (jsr277) {
|
||||
standardAttributes.put(Module, Module_attribute.class);
|
||||
standardAttributes.put(ModuleExportTable, ModuleExportTable_attribute.class);
|
||||
standardAttributes.put(ModuleMemberTable, ModuleMemberTable_attribute.class);
|
||||
}
|
||||
|
||||
if (!compat) { // old javap does not recognize recent attributes
|
||||
standardAttributes.put(CompilationID, CompilationID_attribute.class);
|
||||
standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class);
|
||||
@ -148,7 +133,6 @@ public abstract class Attribute {
|
||||
|
||||
private Map<String,Class<? extends Attribute>> standardAttributes;
|
||||
private boolean compat; // don't support recent attrs in compatibility mode
|
||||
private boolean jsr277; // support new jsr277 attrs
|
||||
}
|
||||
|
||||
public static Attribute read(ClassReader cr) throws IOException {
|
||||
@ -201,9 +185,5 @@ public abstract class Attribute {
|
||||
R visitStackMap(StackMap_attribute attr, P p);
|
||||
R visitStackMapTable(StackMapTable_attribute attr, P p);
|
||||
R visitSynthetic(Synthetic_attribute attr, P p);
|
||||
|
||||
R visitModule(Module_attribute attr, P p);
|
||||
R visitModuleExportTable(ModuleExportTable_attribute attr, P p);
|
||||
R visitModuleMemberTable(ModuleMemberTable_attribute attr, P p);
|
||||
}
|
||||
}
|
||||
|
@ -449,25 +449,6 @@ public class ClassWriter {
|
||||
out.writeShort(entry.index);
|
||||
}
|
||||
|
||||
public Void visitModule(Module_attribute attr, ClassOutputStream out) {
|
||||
out.writeShort(attr.module_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitModuleExportTable(ModuleExportTable_attribute attr, ClassOutputStream out) {
|
||||
out.writeShort(attr.export_type_table.length);
|
||||
for (int i: attr.export_type_table)
|
||||
out.writeShort(i);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, ClassOutputStream out) {
|
||||
out.writeShort(attr.package_member_table.length);
|
||||
for (int i: attr.package_member_table)
|
||||
out.writeShort(i);
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, ClassOutputStream out) {
|
||||
annotationWriter.write(attr.annotations, out);
|
||||
return null;
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.classfile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* See JSR 277.
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class ModuleExportTable_attribute extends Attribute {
|
||||
ModuleExportTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
|
||||
super(name_index, length);
|
||||
int export_type_length = cr.readUnsignedShort();
|
||||
export_type_table = new int[export_type_length];
|
||||
for (int i = 0; i < export_type_table.length; i++)
|
||||
export_type_table[i] = cr.readUnsignedShort();
|
||||
}
|
||||
|
||||
public ModuleExportTable_attribute(ConstantPool cp, int[] export_type_table)
|
||||
throws ConstantPoolException {
|
||||
this(cp.getUTF8Index(Attribute.ModuleExportTable), export_type_table);
|
||||
}
|
||||
|
||||
public ModuleExportTable_attribute(int name_index, int[] export_type_table) {
|
||||
super(name_index, 2 + 2 * export_type_table.length);
|
||||
this.export_type_table = export_type_table;
|
||||
}
|
||||
|
||||
public int getExportTypeCount() {
|
||||
return export_type_table.length;
|
||||
}
|
||||
|
||||
public String getExportTypeName(int index, ConstantPool constant_pool) throws ConstantPoolException {
|
||||
return constant_pool.getUTF8Value(export_type_table[index]);
|
||||
}
|
||||
|
||||
public <R, P> R accept(Visitor<R, P> visitor, P p) {
|
||||
return visitor.visitModuleExportTable(this, p);
|
||||
}
|
||||
|
||||
public final int[] export_type_table;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
package com.sun.tools.classfile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* See JSR 277.
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class ModuleMemberTable_attribute extends Attribute {
|
||||
ModuleMemberTable_attribute(ClassReader cr, int name_index, int length) throws IOException {
|
||||
super(name_index, length);
|
||||
int package_member_length = cr.readUnsignedShort();
|
||||
package_member_table = new int[package_member_length];
|
||||
for (int i = 0; i < package_member_table.length; i++)
|
||||
package_member_table[i] = cr.readUnsignedShort();
|
||||
}
|
||||
|
||||
public ModuleMemberTable_attribute(ConstantPool cp, int[] package_member_table)
|
||||
throws ConstantPoolException {
|
||||
this(cp.getUTF8Index(Attribute.ModuleMemberTable), package_member_table);
|
||||
}
|
||||
|
||||
public ModuleMemberTable_attribute(int name_index, int[] package_member_table) {
|
||||
super(name_index, 2 + 2 * package_member_table.length);
|
||||
this.package_member_table = package_member_table;
|
||||
}
|
||||
|
||||
public int getPackageMemberCount() {
|
||||
return package_member_table.length;
|
||||
}
|
||||
|
||||
public String getPackageMemberName(int index, ConstantPool constant_pool) throws ConstantPoolException {
|
||||
return constant_pool.getUTF8Value(package_member_table[index]);
|
||||
}
|
||||
|
||||
public <R, P> R accept(Visitor<R, P> visitor, P p) {
|
||||
return visitor.visitModuleMemberTable(this, p);
|
||||
}
|
||||
|
||||
public final int[] package_member_table;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Sun designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Sun in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package com.sun.tools.classfile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* See JSR 277.
|
||||
*
|
||||
* <p><b>This is NOT part of any API supported by Sun Microsystems. If
|
||||
* you write code that depends on this, you do so at your own risk.
|
||||
* This code and its internal interfaces are subject to change or
|
||||
* deletion without notice.</b>
|
||||
*/
|
||||
public class Module_attribute extends Attribute {
|
||||
Module_attribute(ClassReader cr, int name_index, int length) throws IOException {
|
||||
super(name_index, length);
|
||||
module_name = cr.readUnsignedShort();
|
||||
}
|
||||
|
||||
public Module_attribute(ConstantPool constant_pool, int module_name)
|
||||
throws ConstantPoolException {
|
||||
this(constant_pool.getUTF8Index(Attribute.Module), module_name);
|
||||
}
|
||||
|
||||
public Module_attribute(int name_index, int module_name) {
|
||||
super(name_index, 2);
|
||||
this.module_name = module_name;
|
||||
}
|
||||
|
||||
public String getModuleName(ConstantPool constant_pool) throws ConstantPoolException {
|
||||
return constant_pool.getUTF8Value(module_name);
|
||||
}
|
||||
|
||||
public <R, D> R accept(Visitor<R, D> visitor, D data) {
|
||||
return visitor.visitModule(this, data);
|
||||
}
|
||||
|
||||
public final int module_name;
|
||||
|
||||
}
|
@ -45,9 +45,6 @@ import com.sun.tools.classfile.InnerClasses_attribute;
|
||||
import com.sun.tools.classfile.LineNumberTable_attribute;
|
||||
import com.sun.tools.classfile.LocalVariableTable_attribute;
|
||||
import com.sun.tools.classfile.LocalVariableTypeTable_attribute;
|
||||
import com.sun.tools.classfile.ModuleExportTable_attribute;
|
||||
import com.sun.tools.classfile.ModuleMemberTable_attribute;
|
||||
import com.sun.tools.classfile.Module_attribute;
|
||||
import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
|
||||
import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
|
||||
import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
|
||||
@ -372,63 +369,6 @@ public class AttributeWriter extends BasicWriter
|
||||
return null;
|
||||
}
|
||||
|
||||
public Void visitModule(Module_attribute attr, Void ignore) {
|
||||
print("Module: #" + attr.module_name);
|
||||
tab();
|
||||
println("// " + getModuleName(attr));
|
||||
return null;
|
||||
}
|
||||
|
||||
String getModuleName(Module_attribute attr) {
|
||||
try {
|
||||
return attr.getModuleName(constant_pool);
|
||||
} catch (ConstantPoolException e) {
|
||||
return report(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Void visitModuleExportTable(ModuleExportTable_attribute attr, Void ignore) {
|
||||
println("ModuleExportTable:");
|
||||
indent(+1);
|
||||
println("Types: (" + attr.export_type_table.length + ")");
|
||||
for (int i = 0; i < attr.export_type_table.length; i++) {
|
||||
print("#" + attr.export_type_table[i]);
|
||||
tab();
|
||||
println("// " + getExportTypeName(attr, i));
|
||||
}
|
||||
indent(-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
String getExportTypeName(ModuleExportTable_attribute attr, int index) {
|
||||
try {
|
||||
return attr.getExportTypeName(index, constant_pool);
|
||||
} catch (ConstantPoolException e) {
|
||||
return report(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Void visitModuleMemberTable(ModuleMemberTable_attribute attr, Void ignore) {
|
||||
println("ModuleMemberTable:");
|
||||
indent(+1);
|
||||
println("Packages: (" + attr.package_member_table.length + ")");
|
||||
for (int i = 0; i < attr.package_member_table.length; i++) {
|
||||
print("#" + attr.package_member_table[i]);
|
||||
tab();
|
||||
println("// " + getPackageMemberName(attr, i));
|
||||
}
|
||||
indent(-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
String getPackageMemberName(ModuleMemberTable_attribute attr, int index) {
|
||||
try {
|
||||
return attr.getPackageMemberName(index, constant_pool);
|
||||
} catch (ConstantPoolException e) {
|
||||
return report(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Void visitRuntimeVisibleAnnotations(RuntimeVisibleAnnotations_attribute attr, Void ignore) {
|
||||
println("RuntimeVisibleAnnotations:");
|
||||
indent(+1);
|
||||
|
@ -236,12 +236,6 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-XDjsr277") {
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.jsr277 = true;
|
||||
}
|
||||
},
|
||||
|
||||
new Option(false, "-XDdetails") {
|
||||
void process(JavapTask task, String opt, String arg) {
|
||||
task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class);
|
||||
@ -586,7 +580,6 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages {
|
||||
sourceWriter.setFileManager(fileManager);
|
||||
|
||||
attributeFactory.setCompat(options.compat);
|
||||
attributeFactory.setJSR277(options.jsr277);
|
||||
|
||||
boolean ok = true;
|
||||
|
||||
|
@ -90,5 +90,4 @@ public class Options {
|
||||
public int tabColumn = 40; // column number for comments
|
||||
|
||||
public boolean compat; // bug-for-bug compatibility mode with old javap
|
||||
public boolean jsr277;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user