Reference instead of String[3]

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@484 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 66ca7ba07a
commit 08f7ce61e5
  1. 20
      jode/jode/bytecode/ConstantPool.java

@ -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");
if (constants[i] == null) {
int classIndex = indices1[i]; int classIndex = indices1[i];
int nameTypeIndex = indices2[i]; int nameTypeIndex = indices2[i];
if (tags[nameTypeIndex] != NAMEANDTYPE) if (tags[nameTypeIndex] != NAMEANDTYPE)
throw new ClassFormatException("Tag mismatch"); throw new ClassFormatException("Tag mismatch");
return new String[] { constants[i] = new Reference
getClassName(classIndex), (getClassName(classIndex),
getUTF8(indices1[nameTypeIndex]), getUTF8(indices2[nameTypeIndex]) 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) {

Loading…
Cancel
Save