From 356d2a0aa11ad1b65fd631edde72000935e9ca49 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 12 Mar 1999 19:23:44 +0000 Subject: [PATCH] getConstant added git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@392 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/bytecode/ConstantPool.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/jode/jode/bytecode/ConstantPool.java b/jode/jode/bytecode/ConstantPool.java index 43d1e43..af4ced9 100644 --- a/jode/jode/bytecode/ConstantPool.java +++ b/jode/jode/bytecode/ConstantPool.java @@ -144,6 +144,21 @@ public class ConstantPool { } } + public Object getConstant(int i) throws ClassFormatException { + if (i == 0) + throw new ClassFormatException("null constant"); + switch (tags[i]) { + case ConstantPool.INTEGER: + case ConstantPool.FLOAT: + case ConstantPool.LONG: + case ConstantPool.DOUBLE: + return constants[i]; + case ConstantPool.STRING: + return getUTF8(indices1[i]); + } + throw new ClassFormatException("unknown constant tag: "+tags[i]); + } + public int getConstantInt(int i) throws ClassFormatException { if (i == 0 || tags[i] != ConstantPool.INTEGER) throw new ClassFormatException("not an integer "+tags[i]);