From 5765d534a5437b624646ff20ca487346fa76a267 Mon Sep 17 00:00:00 2001 From: mkersten Date: Thu, 27 Jan 2005 17:21:17 +0000 Subject: [PATCH] Tests and fix for: Bug 83565 BCException "bad type name" thrown when compiling --- ajde/testdata/bug-83565/Bug.java | 23 ++++++++ ajde/testdata/bug-83565/build.lst | 3 ++ ajde/testsrc/org/aspectj/ajde/AjdeTests.java | 1 + .../org/aspectj/ajde/GenericsTest.java | 25 +++++++++ .../core/builder/AsmHierarchyBuilder.java | 52 +++++-------------- 5 files changed, 65 insertions(+), 39 deletions(-) create mode 100644 ajde/testdata/bug-83565/Bug.java create mode 100644 ajde/testdata/bug-83565/build.lst create mode 100644 ajde/testsrc/org/aspectj/ajde/GenericsTest.java diff --git a/ajde/testdata/bug-83565/Bug.java b/ajde/testdata/bug-83565/Bug.java new file mode 100644 index 000000000..44506e013 --- /dev/null +++ b/ajde/testdata/bug-83565/Bug.java @@ -0,0 +1,23 @@ + +package mj.compiler.ast; + +import java.util.Vector; + +class Sequence extends AST { + + private Vector elements = new Vector(); + + public Sequence(T element) { +// super(element); + elements.add(element); + } + + public int length() { return elements.size(); } + public T elementAt(int i) { return elements.elementAt(i); } +} + +class AST { + public AST() { } + + public AST(T element) { } +} \ No newline at end of file diff --git a/ajde/testdata/bug-83565/build.lst b/ajde/testdata/bug-83565/build.lst new file mode 100644 index 000000000..95c39c932 --- /dev/null +++ b/ajde/testdata/bug-83565/build.lst @@ -0,0 +1,3 @@ +-1.5 +Bug.java + diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index c0c0b5857..d57c179fa 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -40,6 +40,7 @@ public class AjdeTests extends TestCase { suite.addTestSuite(BuildCancellingTest.class); suite.addTestSuite(JarManifestTest.class); suite.addTestSuite(ExtensionTests.class); + suite.addTestSuite(GenericsTest.class); //$JUnit-END$ return suite; diff --git a/ajde/testsrc/org/aspectj/ajde/GenericsTest.java b/ajde/testsrc/org/aspectj/ajde/GenericsTest.java new file mode 100644 index 000000000..d3a962d5b --- /dev/null +++ b/ajde/testsrc/org/aspectj/ajde/GenericsTest.java @@ -0,0 +1,25 @@ +/* + * Created on Jan 27, 2005 + */ +package org.aspectj.ajde; + +import org.aspectj.asm.AsmManager; + +/** + * @author Mik Kersten + */ +public class GenericsTest extends AjdeTestCase { + + private AsmManager manager = null; + private static final String CONFIG_FILE_PATH = "../bug-83565/build.lst"; + + public void testBuild() { +// assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH)); + } + + protected void setUp() throws Exception { + super.setUp("examples"); + manager = AsmManager.getDefault(); + } + +} diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java index edcba82c9..f77f10f0a 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java @@ -16,54 +16,24 @@ package org.aspectj.ajdt.internal.core.builder; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.Stack; - -import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration; -import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration; -import org.aspectj.ajdt.internal.compiler.ast.InterTypeDeclaration; -import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration; +import java.util.*; + +import org.aspectj.ajdt.internal.compiler.ast.*; import org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment; import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; -import org.aspectj.asm.AsmManager; -import org.aspectj.asm.IHierarchy; -import org.aspectj.asm.IProgramElement; -import org.aspectj.asm.IRelationship; +import org.aspectj.asm.*; import org.aspectj.asm.internal.ProgramElement; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.SourceLocation; import org.aspectj.org.eclipse.jdt.internal.compiler.ASTVisitor; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ASTNode; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.ImportReference; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Initializer; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.*; import org.aspectj.org.eclipse.jdt.internal.compiler.env.IGenericType; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BlockScope; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.*; import org.aspectj.org.eclipse.jdt.internal.compiler.problem.ProblemHandler; import org.aspectj.util.LangUtil; -import org.aspectj.weaver.Member; -import org.aspectj.weaver.ResolvedMember; -import org.aspectj.weaver.TypeX; -import org.aspectj.weaver.World; -import org.aspectj.weaver.patterns.AndPointcut; -import org.aspectj.weaver.patterns.OrPointcut; -import org.aspectj.weaver.patterns.Pointcut; -import org.aspectj.weaver.patterns.ReferencePointcut; +import org.aspectj.weaver.*; +import org.aspectj.weaver.patterns.*; /** * At each iteration of processCompilationUnit the declarations for a @@ -486,10 +456,12 @@ public class AsmHierarchyBuilder extends ASTVisitor { if (methodDeclaration.binding != null) { String memberName = ""; String memberBytecodeSignature = ""; - try { + try { Member member = EclipseFactory.makeResolvedMember(methodDeclaration.binding); memberName = member.getName(); memberBytecodeSignature = member.getSignature(); + } catch (BCException bce) { // bad type name + memberName = ""; } catch (NullPointerException npe) { memberName = ""; } @@ -675,6 +647,8 @@ public class AsmHierarchyBuilder extends ASTVisitor { Member member = EclipseFactory.makeResolvedMember(constructorDeclaration.binding); memberName = member.getName(); memberBytecodeSignature = member.getSignature(); + } catch (BCException bce) { // bad type name + memberName = ""; } catch (NullPointerException npe) { memberName = ""; } -- 2.39.5