diff options
Diffstat (limited to 'tests')
6 files changed, 59 insertions, 11 deletions
diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java index 5d469fbd3..205e0802c 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ltw/LTWTests.java @@ -116,7 +116,7 @@ public class LTWTests extends org.aspectj.testing.XMLBasedAjcTestCase { } public void testJ14LTWWithXML() { - runTest("JDK14 LTW with XML"); + runTest("JDK14 LTW with XML"); } // public void testJ14LTWWithASPECTPATH() { diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java index 9ef043b8a..edbd540ab 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc152/Ajc152Tests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM + * Copyright (c) 2006 IBM * 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 @@ -368,8 +368,8 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase { IProgramElement ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.METHOD, ipeLabel); assertNotNull("Couldn't find '" + ipeLabel + "' element in the tree", ipe); List<char[]> l = ipe.getParameterSignatures(); - boolean eq = CharOperation.equals(((char[]) l.get(0)), expectedParm.toCharArray()); - assertTrue("expected parameter to be '" + expectedParm + "' but found '" + new String(((char[]) l.get(0))) + "'", eq); + boolean eq = CharOperation.equals((l.get(0)), expectedParm.toCharArray()); + assertTrue("expected parameter to be '" + expectedParm + "' but found '" + new String((l.get(0))) + "'", eq); } // /////////////////////////////////////// diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java b/tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java index d1c7c2ced..00bae65e4 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc196/Ajc196Tests.java @@ -18,6 +18,10 @@ import junit.framework.Test; */ public class Ajc196Tests extends XMLBasedAjcTestCaseForJava14OrLater { + public void testNPE_558995() { + runTest("early resolution of supporting interfaces"); + } + public void testRecords() { runTest("simple record"); checkVersion("Person", Constants.MAJOR_14, Constants.PREVIEW_MINOR_VERSION); diff --git a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java index c3e44bcbc..0efff1b99 100644 --- a/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/incremental/tools/IncrementalCompilationTests.java @@ -4,14 +4,16 @@ * 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: * Andy Clement (SpringSource) initial implementation *******************************************************************/ package org.aspectj.systemtest.incremental.tools; import java.io.File; +import java.lang.ref.Reference; import java.util.List; +import java.util.Map; import java.util.Set; import org.aspectj.ajde.core.AjCompiler; @@ -29,9 +31,11 @@ import org.aspectj.weaver.World; import org.aspectj.weaver.World.TypeMap; /** - * Incremental compilation tests. MultiProjectIncrementalTests was getting unwieldy - started this new test class for 1.6.10. - * + * Incremental compilation tests. MultiProjectIncrementalTests was getting + * unwieldy - started this new test class for 1.6.10. + * * @author Andy Clement + * @author Joseph MacFarlane * @since 1.6.10 */ public class IncrementalCompilationTests extends AbstractMultiProjectIncrementalAjdeInteractionTestbed { @@ -471,6 +475,42 @@ public class IncrementalCompilationTests extends AbstractMultiProjectIncremental assertEquals("Pjava/util/List<Ljava/lang/Integer;>;", fields[3].getGenericReturnType().getSignature()); } + public void testExpendableMapEntryReplacement() throws Exception { + String p = "PR278496_5"; + initialiseProject(p); + configureNonStandardCompileOptions(p, "-Xset:typeDemotion=true"); + build(p); + checkWasFullBuild(); + alter(p, "inc1"); + build(p); + checkWasntFullBuild(); + AjdeCoreBuildManager buildManager = getCompilerForProjectWithName(p).getBuildManager(); + AjBuildManager ajBuildManager = buildManager.getAjBuildManager(); + World w = ajBuildManager.getWorld(); + + // Hold onto the signature but GC the type... + String signature = w.resolveToReferenceType("com.Foo").getSignature(); + System.gc(); + assertTrue("Map entry still present", w.getTypeMap().getExpendableMap().containsKey(signature)); + assertNull("Type has been GC'd", w.getTypeMap().getExpendableMap().get(signature).get()); + + // Re-resolve the type and check that it has a new instance of the signature + // String + ReferenceType referenceType = w.resolveToReferenceType("com.Foo"); + assertNotSame("New type has a new signature.", System.identityHashCode(signature), + System.identityHashCode(referenceType.getSignature())); + + Map.Entry<String, Reference<ResolvedType>> entry = null; + for (Map.Entry<String, Reference<ResolvedType>> e : w.getTypeMap().getExpendableMap().entrySet()) { + if (referenceType.getSignature().equals(e.getKey())) { + entry = e; + } + } + assertEquals( + "Map is keyed by the same String instance that is the re-resolved type's signature, not by the previous instance.", + System.identityHashCode(referenceType.getSignature()), System.identityHashCode(entry.getKey())); + } + /** * This test is verifying the treatment of array types (here, String[]). These should be expendable but because the * ArrayReferenceType wasnt overriding isExposedToWeaver() an array had an apparent null delegate - this caused the isExpendable @@ -757,8 +797,8 @@ public class IncrementalCompilationTests extends AbstractMultiProjectIncremental private String stringify(Object[] arr) { StringBuilder s = new StringBuilder(); - for (int i = 0; i < arr.length; i++) { - s.append(arr[i]); + for (Object element : arr) { + s.append(element); s.append(" "); } return "[" + s.toString().trim() + "]"; diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml index 685b50240..187fb50b3 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc188/ajc188.xml @@ -16,7 +16,7 @@ <compile files="Test2.java" options="-1.8 -XnoInline"/> </ajc-test> -<ajc-test dir="bugs188/defaultmethods" title="default methods 1"> +<ajc-test dir="bugs188/defaultMethods" title="default methods 1"> <compile files="Code.java" options="-1.8 -XnoInline"/> <run class="Code"> <stdout> @@ -27,7 +27,7 @@ </ajc-test> -<ajc-test dir="bugs188/defaultmethods" title="default methods 2"> +<ajc-test dir="bugs188/defaultMethods" title="default methods 2"> <compile files="Code2.java" options="-1.8"/> <run class="Code2"> <stdout> diff --git a/tests/src/test/resources/org/aspectj/systemtest/ajc196/ajc196.xml b/tests/src/test/resources/org/aspectj/systemtest/ajc196/ajc196.xml index cd5a4870a..69a9fd8bf 100644 --- a/tests/src/test/resources/org/aspectj/systemtest/ajc196/ajc196.xml +++ b/tests/src/test/resources/org/aspectj/systemtest/ajc196/ajc196.xml @@ -2,6 +2,10 @@ <suite> + <ajc-test dir="bugs196/558995" title="early resolution of supporting interfaces"> + <compile options="-14" files="foo/SynchronizedStaticAspect.aj foo/SynchronizedAspect.aj foo/SynchronizedTest.java foo/Synchronized.java"/> + </ajc-test> + <!-- switch now in Java14 and doesn't need -enable-preview flag --> <ajc-test dir="features193" vm="14" title="switch 1"> <compile files="Switch1.java" options="-14"> |