From: aclement Date: Tue, 6 Jun 2006 08:38:28 +0000 (+0000) Subject: some code for 141730 - store type signatures in program elements rather than processe... X-Git-Tag: V1_5_2rc1~65 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5e74f35fa0ac6002b0a291259b88c1b0017fbf40;p=aspectj.git some code for 141730 - store type signatures in program elements rather than processed type names. --- diff --git a/asm/.classpath b/asm/.classpath index 5781c41ae..a96910321 100644 --- a/asm/.classpath +++ b/asm/.classpath @@ -1,9 +1,10 @@ - - - - - - + + + + + + + diff --git a/asm/src/org/aspectj/asm/AsmManager.java b/asm/src/org/aspectj/asm/AsmManager.java index e9b8c4bc1..f7d0c677e 100644 --- a/asm/src/org/aspectj/asm/AsmManager.java +++ b/asm/src/org/aspectj/asm/AsmManager.java @@ -77,8 +77,9 @@ public class AsmManager { handleProvider = new OptimizedFullPathHandleProvider(); } - public void createNewASM() { + public void createNewASM(INameConvertor convertor) { hierarchy = new AspectJElementHierarchy(); + hierarchy.setNameConvertor(convertor); mapper = new RelationshipMap(hierarchy); } diff --git a/asm/src/org/aspectj/asm/IHierarchy.java b/asm/src/org/aspectj/asm/IHierarchy.java index d458da338..82428481b 100644 --- a/asm/src/org/aspectj/asm/IHierarchy.java +++ b/asm/src/org/aspectj/asm/IHierarchy.java @@ -102,4 +102,7 @@ public interface IHierarchy extends Serializable { public void flushHandleMap(); public void updateHandleMap(Set deletedFiles); + + public void setNameConvertor(INameConvertor convertor); + public INameConvertor getNameConvertor(); } \ No newline at end of file diff --git a/asm/src/org/aspectj/asm/INameConvertor.java b/asm/src/org/aspectj/asm/INameConvertor.java new file mode 100644 index 000000000..58197bbf7 --- /dev/null +++ b/asm/src/org/aspectj/asm/INameConvertor.java @@ -0,0 +1,17 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version + *******************************************************************/ +package org.aspectj.asm; + +public interface INameConvertor { + + public char[] convertName(char[] name); + +} diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index d0024aac8..f88c2dbba 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -116,12 +116,13 @@ public interface IProgramElement extends Serializable { public String toLabelString(); public String toLabelString(boolean getFullyQualifiedArgTypes); - public List getParameterTypes(); - public void setParameterTypes(List list); - public List getParameterNames(); public void setParameterNames(List list); + public List getParameterSignatures(); + public void setParameterSignatures(List list); + public List getParameterTypes(); + /** * The format of the string handle is not specified, but is stable across * compilation sessions. diff --git a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java index 42c60a203..62a1a31a8 100644 --- a/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java +++ b/asm/src/org/aspectj/asm/internal/AspectJElementHierarchy.java @@ -29,6 +29,7 @@ public class AspectJElementHierarchy implements IHierarchy { protected IProgramElement root = null; protected String configFile = null; + private transient INameConvertor convertor = null; private Map fileMap = null; private Map handleMap = null; @@ -449,5 +450,13 @@ public class AspectJElementHierarchy implements IHierarchy { return hid.substring(0,hid.indexOf("|")); } + public void setNameConvertor(INameConvertor convertor) { + this.convertor = convertor; + } + + public INameConvertor getNameConvertor() { + return convertor; + } + } diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index 35b6a60be..0e8826fc1 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -22,9 +22,11 @@ import java.util.Map; import org.aspectj.asm.AsmManager; import org.aspectj.asm.HierarchyWalker; +import org.aspectj.asm.INameConvertor; import org.aspectj.asm.IProgramElement; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; +import org.aspectj.util.CharOperation; /** @@ -408,16 +410,22 @@ public class ProgramElement implements IProgramElement { sb.append(name); List ptypes = getParameterTypes(); - if (ptypes != null) { + if (ptypes != null && (!ptypes.isEmpty() + || this.kind.equals(IProgramElement.Kind.METHOD)) + || this.kind.equals(IProgramElement.Kind.CONSTRUCTOR) + || this.kind.equals(IProgramElement.Kind.ADVICE) + || this.kind.equals(IProgramElement.Kind.POINTCUT) + || this.kind.equals(IProgramElement.Kind.INTER_TYPE_METHOD) + || this.kind.equals(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR)) { sb.append('('); for (Iterator it = ptypes.iterator(); it.hasNext(); ) { - String arg = (String)it.next(); + char[] arg = (char[])it.next(); if (getFullyQualifiedArgTypes) { sb.append(arg); } else { - int index = arg.lastIndexOf("."); + int index = CharOperation.lastIndexOf('.',arg); if (index != -1) { - sb.append(arg.substring(index + 1)); + sb.append(CharOperation.subarray(arg,index+1,arg.length)); } else { sb.append(arg); } @@ -503,17 +511,35 @@ public class ProgramElement implements IProgramElement { //parameterNames = list; } - public List getParameterTypes() { - List parameterTypes = (List)kvpairs.get("parameterTypes"); - return parameterTypes; + public List getParameterTypes() { + List l = getParameterSignatures(); + if (l == null || l.isEmpty()) { + return Collections.EMPTY_LIST; + } + List params = new ArrayList(); + for (Iterator iter = l.iterator(); iter.hasNext();) { + char[] param = (char[])iter.next(); + INameConvertor convertor = AsmManager.getDefault().getHierarchy().getNameConvertor(); + if (convertor != null) { + params.add(convertor.convertName(param)); + } else { + params.add(param); + } + } + return params; } - public void setParameterTypes(List list) { - if (kvpairs==Collections.EMPTY_MAP) kvpairs = new HashMap(); - if (list==null || list.size()==0) kvpairs.put("parameterTypes",Collections.EMPTY_LIST); - else kvpairs.put("parameterTypes",list); -// parameterTypes = list; + + public List getParameterSignatures() { + List parameters = (List)kvpairs.get("parameterSigs"); + return parameters; } + public void setParameterSignatures(List list) { + if (kvpairs==Collections.EMPTY_MAP) kvpairs = new HashMap(); + if (list==null || list.size()==0) kvpairs.put("parameterSigs",Collections.EMPTY_LIST); + else kvpairs.put("parameterSigs",list); + } + public String getDetails() { String details = (String)kvpairs.get("details"); return details; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index d2b09def2..ac3f04b53 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -49,6 +49,7 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; import org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IHierarchy; +import org.aspectj.asm.INameConvertor; import org.aspectj.asm.IProgramElement; import org.aspectj.asm.internal.ProgramElement; import org.aspectj.bridge.AbortException; @@ -83,6 +84,8 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblemFacto import org.aspectj.util.FileUtil; import org.aspectj.weaver.Dump; import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.TypeFactory; +import org.aspectj.weaver.UnresolvedType; import org.aspectj.weaver.World; import org.aspectj.weaver.bcel.BcelWeaver; import org.aspectj.weaver.bcel.BcelWorld; @@ -631,7 +634,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc AsmManager.setCreatingModel(config.isEmacsSymMode() || config.isGenerateModelMode()); if (!AsmManager.isCreatingModel()) return; - AsmManager.getDefault().createNewASM(); + AsmManager.getDefault().createNewASM(new NameConverter()); // AsmManager.getDefault().getRelationshipMap().clear(); IHierarchy model = AsmManager.getDefault().getHierarchy(); String rootLabel = ""; @@ -1276,5 +1279,15 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc } } + + private class NameConverter implements INameConvertor { + + public char[] convertName(char[] name) { + UnresolvedType ut = TypeFactory.createTypeFromSignature(new String(name)); + ResolvedType rt = getWorld().resolve(ut); + return rt.getName().toCharArray(); + } + + } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java index e254a5135..a7265f761 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmElementFormatter.java @@ -25,7 +25,14 @@ import org.aspectj.ajdt.internal.compiler.ast.InterTypeFieldDeclaration; import org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration; import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration; import org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment; +import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; import org.aspectj.asm.IProgramElement; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; +import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.weaver.AdviceKind; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.UnresolvedType; @@ -39,13 +46,6 @@ import org.aspectj.weaver.patterns.OrPointcut; import org.aspectj.weaver.patterns.ReferencePointcut; import org.aspectj.weaver.patterns.TypePattern; import org.aspectj.weaver.patterns.TypePatternList; -import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; -import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; /** * @author Mik Kersten @@ -296,34 +296,31 @@ public class AsmElementFormatter { Argument[] argArray = md.arguments; if (argArray == null) { pe.setParameterNames(Collections.EMPTY_LIST); - pe.setParameterTypes(Collections.EMPTY_LIST); + pe.setParameterSignatures(Collections.EMPTY_LIST); } else { List names = new ArrayList(); - List types = new ArrayList(); - + List paramSigs = new ArrayList(); for (int i = 0; i < argArray.length; i++) { String argName = new String(argArray[i].name); - String argType = ""; // pr135052 - TypeReference typeR = argArray[i].type; - if (typeR!=null) { - TypeBinding typeB = typeR.resolvedType; - if (typeB==null) { - if (typeR.getTypeName()!=null) - argType = CharOperation.toString(typeR.getTypeName()); - } else { - argType = typeB.debugName(); + //String argType = ""; // pr135052 + if (acceptArgument(argName, argArray[i].type.toString())) { + TypeReference typeR = argArray[i].type; + if (typeR!=null) { + TypeBinding typeB = typeR.resolvedType; + if (typeB==null) { + typeB = typeR.resolveType(md.scope); + } + EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(md.scope); + UnresolvedType ut = factory.fromBinding(typeB); + paramSigs.add(ut.getSignature().toCharArray()); } - } - - -// String argType = argArray[i].type.resolvedType.debugName(); - if (acceptArgument(argName, argArray[i].type.toString())) { names.add(argName); - types.add(argType); - } + } } pe.setParameterNames(names); - pe.setParameterTypes(types); + if (!paramSigs.isEmpty()) { + pe.setParameterSignatures(paramSigs); + } } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java index b9f2c9662..4522a8b33 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java @@ -52,7 +52,7 @@ public class IncrementalStateManager { element.wipeAllKnowledge(); } incrementalStates.clear(); - AsmManager.getDefault().createNewASM(); // forget what you know... + AsmManager.getDefault().createNewASM(null); // forget what you know... } public static Set getConfigFilesKnown() { diff --git a/tests/bugs152/pr141730.aj b/tests/bugs152/pr141730.aj new file mode 100644 index 000000000..65b90d37a --- /dev/null +++ b/tests/bugs152/pr141730.aj @@ -0,0 +1,46 @@ +import java.util.List; + +aspect A { + + pointcut p() : execution(* *.*(..)); + + before() : p() {} + + public void MyClass.method() {} + + public MyClass.new() {super();} +} + +class C { + + public C() {} + + public void method() {} + + public void intMethod(int i) {} + + public void stringMethod(String s) {} + + public void myClassMethod(MyClass s) {} + + public void genericMethod(List l) {} + + public void twoArgsMethod(int i, String s) {} + + public void genericMethod2(MyGenericClass m) {} + + public static void main(String[] args) {} + + public void multiMethod(String[][] s) {} + + public void intArray(int[] i) {} + +} + +class MyClass { + + public MyClass(String s) {} + +} + +class MyGenericClass {} diff --git a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java index 3f9896ab4..8e9d48fe8 100644 --- a/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java @@ -109,7 +109,7 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { IProgramElement pe2 = top.findElementForType("pkg","printParameters"); assertNotNull("Couldn't find 'printParameters' element in the tree",pe2); // the argument is org.aspectj.lang.JoinPoint, check that this is added - assertFalse("printParameters method should have arguments",pe2.getParameterTypes().isEmpty()); + assertFalse("printParameters method should have arguments",pe2.getParameterSignatures().isEmpty()); } public void testParameterizedEnum_pr126316() { @@ -156,8 +156,8 @@ public class Ajc151Tests extends org.aspectj.testing.XMLBasedAjcTestCase { IProgramElement.Kind.INTER_TYPE_FIELD,"Bar.children"); assertNotNull("Couldn't find 'Bar.children' element in the tree",field); IProgramElement constructor = top.findElementForLabel(top.getRoot(), - IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR,"Foo.Foo(List)"); - assertNotNull("Couldn't find 'Foo.Foo(List)' element in the tree",constructor); + IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR,"Foo.Foo(java.util.List)"); + assertNotNull("Couldn't find 'Foo.Foo(java.util.List)' element in the tree",constructor); // check that the relationship map has 'itd method declared on bar' List matches = AsmManager.getDefault().getRelationshipMap().get(method); diff --git a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java index e27efeffa..0500cf757 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -11,6 +11,7 @@ package org.aspectj.systemtest.ajc152; import java.io.File; +import java.util.ArrayList; import java.util.List; import junit.framework.Test; @@ -128,6 +129,60 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testJarChecking_pr137235_2() { runTest("directory with .jar extension"); } public void testMakePreMethodNPE_pr136393() { runTest("NPE in makePreMethod");} + public void testGetParameterHandles_pr141730() { + runTest("new IProgramElement handle methods"); + + checkParametersForIPE("intMethod(int)",IProgramElement.Kind.METHOD,"I",true); + checkParametersForIPE("stringMethod(java.lang.String)",IProgramElement.Kind.METHOD,"Ljava/lang/String;",true); + checkParametersForIPE("myClassMethod(MyClass)",IProgramElement.Kind.METHOD,"LMyClass;",true); + checkParametersForIPE("genericMethod(java.util.List)",IProgramElement.Kind.METHOD,"Pjava/util/List;",true); + checkParametersForIPE("genericMethod2(MyGenericClass)",IProgramElement.Kind.METHOD,"PMyGenericClass;",true); + checkParametersForIPE("main(java.lang.String[])",IProgramElement.Kind.METHOD,"[Ljava/lang/String;",true); + checkParametersForIPE("multiMethod(java.lang.String[][])",IProgramElement.Kind.METHOD,"[[Ljava/lang/String;",true); + checkParametersForIPE("intArray(int[])",IProgramElement.Kind.METHOD,"[I",true); + + IHierarchy top = AsmManager.getDefault().getHierarchy(); + IProgramElement twoArgsMethod = top.findElementForLabel( + top.getRoot(),IProgramElement.Kind.METHOD,"twoArgsMethod(int,java.lang.String)"); + assertNotNull("Couldn't find 'twoArgsMethod(int,java.lang.String)' element in the tree",twoArgsMethod); + List l = twoArgsMethod.getParameterSignatures(); + assertEquals("",((char[])l.get(0))[0],'I'); + boolean eq = equals(((char[])l.get(1)),"Ljava/lang/String;".toCharArray()); + assertTrue("expected parameter to be 'Ljava/lang/String;' but found '" + + new String(((char[])l.get(1))) + "'",eq); + } + + public void testGetParameterTypes_pr141730() { + runTest("new IProgramElement handle methods"); + + checkParametersForIPE("intMethod(int)",IProgramElement.Kind.METHOD,"int",false); + checkParametersForIPE("stringMethod(java.lang.String)",IProgramElement.Kind.METHOD,"java.lang.String",false); + checkParametersForIPE("myClassMethod(MyClass)",IProgramElement.Kind.METHOD,"MyClass",false); + checkParametersForIPE("genericMethod(java.util.List)",IProgramElement.Kind.METHOD,"java.util.List",false); + checkParametersForIPE("genericMethod2(MyGenericClass)",IProgramElement.Kind.METHOD,"MyGenericClass",false); + checkParametersForIPE("main(java.lang.String[])",IProgramElement.Kind.METHOD,"java.lang.String[]",false); + checkParametersForIPE("multiMethod(java.lang.String[][])",IProgramElement.Kind.METHOD,"java.lang.String[][]",false); + checkParametersForIPE("intArray(int[])",IProgramElement.Kind.METHOD,"int[]",false); + } + + public void testToSignatureString_pr141730() { + runTest("new IProgramElement handle methods"); + + checkSignatureOfIPE("main(java.lang.String[])",IProgramElement.Kind.METHOD); + checkSignatureOfIPE("C",IProgramElement.Kind.CLASS); + checkSignatureOfIPE("C()",IProgramElement.Kind.CONSTRUCTOR); + checkSignatureOfIPE("method()",IProgramElement.Kind.METHOD); + checkSignatureOfIPE("p()",IProgramElement.Kind.POINTCUT); + checkSignatureOfIPE("before(): p..",IProgramElement.Kind.ADVICE,"before()"); + checkSignatureOfIPE("MyClass.method()",IProgramElement.Kind.INTER_TYPE_METHOD); + checkSignatureOfIPE("multiMethod(java.lang.String[][])",IProgramElement.Kind.METHOD); + checkSignatureOfIPE("intArray(int[])",IProgramElement.Kind.METHOD); + checkSignatureOfIPE("MyClass.MyClass()",IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR); + } + + + + // public void testFunkyGenericErrorWithITDs_pr126355_2() { // runTest("bizarre generic error with itds - 2"); // // public class Pair affected by pertarget aspect @@ -143,6 +198,55 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // Not valid whilst the ajc compiler forces debug on (ignores -g:none) - it will be green but is invalid, trust me // public void testLongWindedMessages_pr129408() { runTest("long winded ataj messages");} + + // ---------------- helper methods --------------- + + /** + * taken from CharOperation + */ + private final boolean equals(char[] first, char[] second) { + if (first == second) + return true; + if (first == null || second == null) + return false; + if (first.length != second.length) + return false; + + for (int i = first.length; --i >= 0;) + if (first[i] != second[i]) + return false; + return true; + } + + private void checkParametersForIPE(String ipeLabel, IProgramElement.Kind kind, String expectedParm, boolean getHandles) { + IHierarchy top = AsmManager.getDefault().getHierarchy(); + IProgramElement ipe = top.findElementForLabel(top.getRoot(),kind,ipeLabel); + assertNotNull("Couldn't find '" + ipeLabel + "' element in the tree",ipe); + List l = new ArrayList(); + if (getHandles) { + l = ipe.getParameterSignatures(); + } else { + l = ipe.getParameterTypes(); + } + boolean eq = equals(((char[])l.get(0)),expectedParm.toCharArray()); + assertTrue("expected parameter to be '" + expectedParm + "' but found '" + + new String(((char[])l.get(0))) + "'",eq); + } + + private void checkSignatureOfIPE(String ipeLabel, IProgramElement.Kind kind) { + checkSignatureOfIPE(ipeLabel,kind,ipeLabel); + } + + private void checkSignatureOfIPE(String ipeLabel, IProgramElement.Kind kind, String expectedSig) { + IHierarchy top = AsmManager.getDefault().getHierarchy(); + IProgramElement ipe = top.findElementForLabel( + top.getRoot(),kind,ipeLabel); + assertNotNull("Couldn't find '" + ipeLabel + "' element in the tree",ipe); + assertEquals("expected signature to be '"+ expectedSig + "' but was " + + ipe.toSignatureString(true),expectedSig,ipe.toSignatureString(true)); + + } + ///////////////////////////////////////// public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Ajc152Tests.class); diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index dbdbdeda4..54718c6c5 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -602,6 +602,10 @@ + + + + diff --git a/util/src/org/aspectj/util/CharOperation.java b/util/src/org/aspectj/util/CharOperation.java new file mode 100644 index 000000000..423d7258d --- /dev/null +++ b/util/src/org/aspectj/util/CharOperation.java @@ -0,0 +1,48 @@ +/******************************************************************** + * Copyright (c) 2006 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version + *******************************************************************/ +package org.aspectj.util; + + +/** + * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation + * + */ +public class CharOperation { + + /** + * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation + */ + public static final char[] subarray(char[] array, int start, int end) { + if (end == -1) + end = array.length; + if (start > end) + return null; + if (start < 0) + return null; + if (end > array.length) + return null; + + char[] result = new char[end - start]; + System.arraycopy(array, start, result, 0, end - start); + return result; + } + + /** + * Taken from org.aspectj.org.eclipse.jdt.core.compiler.CharOperation + */ + public static final int lastIndexOf(char toBeFound, char[] array) { + for (int i = array.length; --i >= 0;) + if (toBeFound == array[i]) + return i; + return -1; + } + +}