|
|
@ -1,4 +1,4 @@ |
|
|
|
/* jode.bytecode.ConstantPool Copyright (C) 1998 Jochen Hoenicke. |
|
|
|
/* ConstantPool Copyright (C) 1998-1999 Jochen Hoenicke. |
|
|
|
* |
|
|
|
* |
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
@ -16,6 +16,7 @@ |
|
|
|
* |
|
|
|
* |
|
|
|
* $Id$ |
|
|
|
* $Id$ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package jode.bytecode; |
|
|
|
package jode.bytecode; |
|
|
|
import java.io.*; |
|
|
|
import java.io.*; |
|
|
|
import jode.Type; |
|
|
|
import jode.Type; |
|
|
@ -90,7 +91,7 @@ public class ConstantPool { |
|
|
|
indices2[i] = stream.readUnsignedShort(); |
|
|
|
indices2[i] = stream.readUnsignedShort(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case UTF8: |
|
|
|
case UTF8: |
|
|
|
constants[i] = stream.readUTF(); |
|
|
|
constants[i] = stream.readUTF().intern(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
throw new ClassFormatException("unknown constant tag"); |
|
|
|
throw new ClassFormatException("unknown constant tag"); |
|
|
@ -112,20 +113,23 @@ public class ConstantPool { |
|
|
|
return (String)constants[i]; |
|
|
|
return (String)constants[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String[] getRef(int i) throws ClassFormatException { |
|
|
|
public Reference getRef(int i) throws ClassFormatException { |
|
|
|
if (i == 0) |
|
|
|
if (i == 0) |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
if (tags[i] != FIELDREF |
|
|
|
if (tags[i] != FIELDREF |
|
|
|
&& tags[i] != METHODREF && tags[i] != INTERFACEMETHODREF) |
|
|
|
&& tags[i] != METHODREF && tags[i] != INTERFACEMETHODREF) |
|
|
|
throw new ClassFormatException("Tag mismatch"); |
|
|
|
throw new ClassFormatException("Tag mismatch"); |
|
|
|
int classIndex = indices1[i]; |
|
|
|
if (constants[i] == null) { |
|
|
|
int nameTypeIndex = indices2[i]; |
|
|
|
int classIndex = indices1[i]; |
|
|
|
if (tags[nameTypeIndex] != NAMEANDTYPE) |
|
|
|
int nameTypeIndex = indices2[i]; |
|
|
|
throw new ClassFormatException("Tag mismatch"); |
|
|
|
if (tags[nameTypeIndex] != NAMEANDTYPE) |
|
|
|
return new String[] { |
|
|
|
throw new ClassFormatException("Tag mismatch"); |
|
|
|
getClassName(classIndex), |
|
|
|
constants[i] = new Reference |
|
|
|
getUTF8(indices1[nameTypeIndex]), getUTF8(indices2[nameTypeIndex]) |
|
|
|
(getClassName(classIndex), |
|
|
|
}; |
|
|
|
getUTF8(indices1[nameTypeIndex]), |
|
|
|
|
|
|
|
getUTF8(indices2[nameTypeIndex])); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (Reference) constants[i]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Object getConstant(int i) throws ClassFormatException { |
|
|
|
public Object getConstant(int i) throws ClassFormatException { |
|
|
@ -148,7 +152,7 @@ public class ConstantPool { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
if (tags[i] != CLASS) |
|
|
|
if (tags[i] != CLASS) |
|
|
|
throw new ClassFormatException("Tag mismatch"); |
|
|
|
throw new ClassFormatException("Tag mismatch"); |
|
|
|
return getUTF8(indices1[i]); |
|
|
|
return getUTF8(indices1[i]).replace('/', '.'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String toString(int i) { |
|
|
|
public String toString(int i) { |
|
|
|