home *** CD-ROM | disk | FTP | other *** search
- package sun.tools.debug;
-
- import java.io.InputStream;
-
- public class RemoteClass extends RemoteObject {
- String name;
- String sourceName;
- boolean intf;
- RemoteClass superclass;
- RemoteObject loader;
- RemoteClass[] interfaces;
- private RemoteField[] methods;
- private RemoteField[] instanceFields;
- private RemoteField[] staticFields;
-
- RemoteClass(RemoteAgent var1, int var2) {
- super(var1, 16, var2, var1.classClass);
- }
-
- private void getClassInfo() throws Exception {
- if (this.interfaces == null) {
- super.agent.getClassInfo(this);
- }
-
- }
-
- private void loadFields() throws Exception {
- if (this.staticFields == null || this.instanceFields == null) {
- RemoteField[] var1 = super.agent.getFields(super.id);
- int var2 = 0;
-
- for(int var3 = 0; var3 < var1.length; ++var3) {
- if (var1[var3].isStatic()) {
- ++var2;
- }
- }
-
- this.staticFields = new RemoteField[var2];
- this.instanceFields = new RemoteField[var1.length - var2];
- int var4 = 0;
- int var5 = 0;
-
- for(int var6 = 0; var6 < var1.length; ++var6) {
- if (var1[var6].isStatic()) {
- this.staticFields[var5++] = var1[var6];
- } else {
- this.instanceFields[var4++] = var1[var6];
- }
- }
- }
-
- }
-
- public String getName() throws Exception {
- this.getClassInfo();
- return this.name;
- }
-
- public String typeName() throws Exception {
- this.getClassInfo();
- return this.getName();
- }
-
- public boolean isInterface() throws Exception {
- this.getClassInfo();
- return this.intf;
- }
-
- public RemoteClass getSuperclass() throws Exception {
- this.getClassInfo();
- return this.superclass;
- }
-
- public RemoteObject getClassLoader() throws Exception {
- this.getClassInfo();
- return this.loader;
- }
-
- public RemoteClass[] getInterfaces() throws Exception {
- this.getClassInfo();
- return this.interfaces;
- }
-
- public String getSourceFileName() throws Exception {
- this.getClassInfo();
- return this.sourceName;
- }
-
- public InputStream getSourceFile() throws Exception {
- this.getClassInfo();
- return super.agent.getSourceFile(this.name, this.sourceName);
- }
-
- public RemoteField[] getFields() throws Exception {
- return this.getStaticFields();
- }
-
- public RemoteField[] getStaticFields() throws Exception {
- this.loadFields();
- return this.staticFields;
- }
-
- public RemoteField[] getInstanceFields() throws Exception {
- this.loadFields();
- return this.instanceFields;
- }
-
- public RemoteField getField(int var1) throws Exception {
- this.loadFields();
- if (var1 >= 0 && var1 < this.staticFields.length) {
- return this.staticFields[var1];
- } else {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- public RemoteField getField(String var1) throws NoSuchFieldException, Exception {
- this.loadFields();
-
- for(int var2 = 0; var2 < this.staticFields.length; ++var2) {
- if (var1.equals(this.staticFields[var2].getName())) {
- return this.staticFields[var2];
- }
- }
-
- throw new NoSuchFieldException();
- }
-
- public RemoteField getInstanceField(int var1) throws Exception {
- this.loadFields();
- if (var1 >= 0 && var1 < this.instanceFields.length) {
- return this.instanceFields[var1];
- } else {
- throw new ArrayIndexOutOfBoundsException();
- }
- }
-
- public RemoteValue getFieldValue(int var1) throws Exception {
- return this.getField(var1).getValue(super.id);
- }
-
- public RemoteValue getFieldValue(String var1) throws NoSuchFieldException, Exception {
- this.loadFields();
-
- for(int var2 = 0; var2 < this.staticFields.length; ++var2) {
- if (var1.equals(this.staticFields[var2].getName())) {
- return this.staticFields[var2].getValue(super.id);
- }
- }
-
- throw new NoSuchFieldException();
- }
-
- public RemoteField getMethod(String var1) throws NoSuchMethodException, Exception {
- if (this.methods == null) {
- this.methods = super.agent.getMethods(super.id);
- }
-
- for(int var2 = 0; var2 < this.methods.length; ++var2) {
- if (var1.equals(this.methods[var2].getName())) {
- return this.methods[var2];
- }
- }
-
- throw new NoSuchMethodException();
- }
-
- public RemoteField[] getMethods() throws Exception {
- if (this.methods == null) {
- this.methods = super.agent.getMethods(super.id);
- }
-
- return this.methods;
- }
-
- public String[] getMethodNames() throws Exception {
- if (this.methods == null) {
- this.methods = super.agent.getMethods(super.id);
- }
-
- String[] var1 = new String[this.methods.length];
-
- for(int var2 = 0; var2 < this.methods.length; ++var2) {
- var1[var2] = this.methods[var2].getName();
- }
-
- return var1;
- }
-
- public int getMethodLineNumber(String var1) throws NoSuchMethodException, NoSuchLineNumberException, Exception {
- if (this.methods == null) {
- this.methods = super.agent.getMethods(super.id);
- }
-
- for(int var2 = 0; var2 < this.methods.length; ++var2) {
- if (var1.equals(this.methods[var2].getName())) {
- int var3 = super.agent.getMethodLineNumber(super.id, var2);
- if (var3 == -1) {
- throw new NoSuchLineNumberException();
- }
-
- return var3;
- }
- }
-
- throw new NoSuchMethodException();
- }
-
- public int getMethodLineNumber(int var1) throws IndexOutOfBoundsException, NoSuchLineNumberException, Exception {
- if (this.methods == null) {
- this.methods = super.agent.getMethods(super.id);
- }
-
- if (var1 >= 0 && var1 < this.methods.length) {
- int var2 = super.agent.getMethodLineNumber(super.id, var1);
- if (var2 == -1) {
- throw new NoSuchLineNumberException();
- } else {
- return var2;
- }
- } else {
- throw new IndexOutOfBoundsException();
- }
- }
-
- public String setBreakpointLine(int var1) throws Exception {
- return super.agent.setBreakpointLine(this, var1);
- }
-
- public String setBreakpointMethod(RemoteField var1) throws Exception {
- return super.agent.setBreakpointMethod(this, var1);
- }
-
- public String clearBreakpoint(int var1) throws Exception {
- return super.agent.clearBreakpoint(this, var1);
- }
-
- public String clearBreakpointLine(int var1) throws Exception {
- return super.agent.clearBreakpointLine(this, var1);
- }
-
- public String clearBreakpointMethod(RemoteField var1) throws Exception {
- return super.agent.clearBreakpointMethod(this, var1);
- }
-
- private boolean isExceptionClass() throws Exception {
- if (!this.getName().equals("java.lang.Exception") && !this.getName().equals("java.lang.Error")) {
- RemoteClass var1 = this.superclass;
-
- do {
- super.agent.message("isExceptionClass: superClass=" + var1.getName());
- if (var1.getName().equals("java.lang.Exception") || var1.getName().equals("java.lang.Error")) {
- return true;
- }
-
- var1 = var1.getSuperclass();
- } while(!var1.getName().equals("java.lang.Object"));
-
- return false;
- } else {
- return true;
- }
- }
-
- public void catchExceptions() throws Exception {
- if (this.isExceptionClass()) {
- super.agent.catchExceptionClass(this);
- } else {
- throw new ClassCastException();
- }
- }
-
- public void ignoreExceptions() throws Exception {
- if (this.isExceptionClass()) {
- super.agent.ignoreExceptionClass(this);
- } else {
- throw new ClassCastException();
- }
- }
-
- public int[] getLineNumbers() throws Exception {
- this.getClassInfo();
- return super.agent.getLineNumbers(this);
- }
-
- public String description() {
- return this.toString();
- }
-
- public String toString() {
- try {
- this.getClassInfo();
- return RemoteValue.toHex(super.id) + ":" + (this.intf ? "interface" : "class") + "(" + this.getName() + ")";
- } catch (Exception var1) {
- return "<communications errors>";
- }
- }
- }
-