From 44a92e1a04f8f2f1a862f15f9d0b9ed761d05fd4 Mon Sep 17 00:00:00 2001 From: acolyer Date: Tue, 10 Aug 2004 11:08:56 +0000 Subject: fix for Bugzilla Bug 59208 Weaver fails in BCEL for large classe --- weaver/src/org/aspectj/weaver/WeaverMessages.java | 1 + weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java | 18 ++++++++++++++++++ .../src/org/aspectj/weaver/weaver-messages.properties | 1 + 3 files changed, 20 insertions(+) (limited to 'weaver') diff --git a/weaver/src/org/aspectj/weaver/WeaverMessages.java b/weaver/src/org/aspectj/weaver/WeaverMessages.java index d6062530c..bca503756 100644 --- a/weaver/src/org/aspectj/weaver/WeaverMessages.java +++ b/weaver/src/org/aspectj/weaver/WeaverMessages.java @@ -83,6 +83,7 @@ public class WeaverMessages { public static final String AROUND_ON_INTERFACE_STATICINIT = "aroundOnInterfaceStaticInit"; public static final String PROBLEM_GENERATING_METHOD = "problemGeneratingMethod"; + public static final String CLASS_TOO_BIG = "classTooBig"; public static final String ZIPFILE_ENTRY_MISSING = "zipfileEntryMissing"; public static final String ZIPFILE_ENTRY_INVALID = "zipfileEntryInvalid"; diff --git a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java index 3185300fa..7f2faeb33 100644 --- a/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java +++ b/weaver/src/org/aspectj/weaver/bcel/LazyClassGen.java @@ -49,6 +49,7 @@ import org.apache.bcel.generic.RETURN; import org.apache.bcel.generic.Type; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; +import org.aspectj.bridge.SourceLocation; import org.aspectj.util.CollectionUtil; import org.aspectj.weaver.AjAttribute; import org.aspectj.weaver.BCException; @@ -377,6 +378,23 @@ public final class LazyClassGen { } private void writeBack(BcelWorld world) { + if (getConstantPoolGen().getSize() > Short.MAX_VALUE) { + // PR 59208 + // we've generated a class that is just toooooooooo big (you've been generating programs + // again haven't you? come on, admit it, no-one writes classes this big by hand). + // create an empty myGen so that we can give back a return value that doesn't upset the + // rest of the process. + myGen = new ClassGen(myGen.getClassName(), myGen.getSuperclassName(), + myGen.getFileName(), myGen.getAccessFlags(), myGen.getInterfaceNames()); + // raise an error against this compilation unit. + getWorld().showMessage( + IMessage.ERROR, + WeaverMessages.format(WeaverMessages.CLASS_TOO_BIG, + this.getClassName()), + new SourceLocation(new File(myGen.getFileName()),0), null + ); + return; + } if (myType != null && myType.getWeaverState() != null) { myGen.addAttribute(BcelAttributes.bcelAttribute( new AjAttribute.WeaverState(myType.getWeaverState()), diff --git a/weaver/src/org/aspectj/weaver/weaver-messages.properties b/weaver/src/org/aspectj/weaver/weaver-messages.properties index da05f6ba1..3e6caeb53 100644 --- a/weaver/src/org/aspectj/weaver/weaver-messages.properties +++ b/weaver/src/org/aspectj/weaver/weaver-messages.properties @@ -87,6 +87,7 @@ aroundOnInterfaceStaticInit=around on staticinitialization of interface ''{0}'' # Bytecode generation nasties... problemGeneratingMethod=problem generating method {0}.{1} : {2} +classTooBig=The class {0} exceeds the maximum class size supported by the JVM (constant pool too big). # Classpath messages zipfileEntryMissing=zipfile classpath entry does not exist: {0} -- cgit v1.2.3