From 0585583c2628bf8a7de6653f16e52def0a54e16e Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 1 Apr 1999 10:27:55 +0000 Subject: [PATCH] use getConstant instead of reading ConstantValue attribute ourself git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@489 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/decompiler/FieldAnalyzer.java | 44 +++++++++---------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/jode/jode/decompiler/FieldAnalyzer.java b/jode/jode/decompiler/FieldAnalyzer.java index 9bd2a34..9d58194 100644 --- a/jode/jode/decompiler/FieldAnalyzer.java +++ b/jode/jode/decompiler/FieldAnalyzer.java @@ -1,18 +1,18 @@ -/* - * FieldAnalyzer (c) 1998 Jochen Hoenicke +/* FieldAnalyzer Copyright (C) 1998-1999 Jochen Hoenicke. * - * You may distribute under the terms of the GNU General Public License. + * 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 + * the Free Software Foundation; either version 2, or (at your option) + * any later version. * - * IN NO EVENT SHALL JOCHEN HOENICKE BE LIABLE TO ANY PARTY FOR DIRECT, - * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF - * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JOCHEN HOENICKE - * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * This program 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 for more details. * - * JOCHEN HOENICKE SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" - * BASIS, AND JOCHEN HOENICKE HAS NO OBLIGATION TO PROVIDE MAINTENANCE, - * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id$ */ @@ -51,21 +51,10 @@ public class FieldAnalyzer implements Analyzer { AttributeInfo attribute = fd.findAttribute("ConstantValue"); - if (attribute != null) { - try { - byte[] contents = attribute.getContents(); - if (contents.length != 2) - throw new AssertError("ConstantValue attribute" - + " has wrong length"); - int index = (contents[0] & 0xff) << 8 | (contents[1] & 0xff); - ConstantPool cpool = cla.getConstantPool(); - constant = new ConstOperator(cpool.getConstant(index)); - constant.setType(type); - constant.makeInitializer(); - } catch (ClassFormatException ex) { - ex.printStackTrace(Decompiler.err); - throw new AssertError("ClassFormatException"); - } + if (fd.getConstant() != null) { + constant = new ConstOperator(fd.getConstant()); + constant.setType(type); + constant.makeInitializer(); } } @@ -115,4 +104,3 @@ public class FieldAnalyzer implements Analyzer { writer.println(";"); } } -