From 999d9b0c88d4cae8f94025a09641343714cf5d83 Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 14 Oct 2005 08:39:32 +0000 Subject: pr112514: better diagnostics when class format exception occurs. --- .../src/org/aspectj/apache/bcel/classfile/ClassParser.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'bcel-builder/src') diff --git a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java index e2508a00d..ae7f8c92e 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/classfile/ClassParser.java @@ -70,7 +70,7 @@ import java.util.zip.*; * JVM specification 1.0. See this paper for * further details about the structure of a bytecode file. * - * @version $Id: ClassParser.java,v 1.3 2005/09/14 11:10:57 aclement Exp $ + * @version $Id: ClassParser.java,v 1.4 2005/10/14 08:39:32 aclement Exp $ * @author M. Dahm */ public final class ClassParser { @@ -252,7 +252,16 @@ public final class ClassParser { */ private final void readConstantPool() throws IOException, ClassFormatException { - constant_pool = new ConstantPool(file); + try { + constant_pool = new ConstantPool(file); + } catch (ClassFormatException cfe) { + // add some context if we can + if (file_name!=null) { + String newmessage = "File: '"+file_name+"': "+cfe.getMessage(); + throw new ClassFormatException(newmessage); // this loses the old stack trace but I dont think that matters! + } + throw cfe; + } } /** -- cgit v1.2.3