From 6be777e71708df5a62e41c6ef95da66bfd02f447 Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Tue, 23 Mar 2021 12:55:48 +0700 Subject: [PATCH] Fix AtAjLTWTests::testLTWDumpProxy for Java 16 Before Java 16, JDK proxies were given a virtual package name of 'com.sun.proxy'. Now the packages are numbered 'jdk.proxy[n]', i.e. 'jdk.proxy1', 'jdk.proxy2' etc. This makes the package-name-derived path name here less predictable. In our simple runtime scenario, we can be pretty sure than the counter starts at 1 because it is the first and only proxy we create. TODO: A better solution would be a recursive filtered search via Files.walk, ideally added as a recursive search option for CountingFilenameFilter. Signed-off-by: Alexander Kriegisch --- .../ajc150/ataspectj/AtAjLTWTests.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java index 16f7321a9..15f3f0796 100644 --- a/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java +++ b/tests/src/test/java/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java @@ -19,6 +19,8 @@ import org.aspectj.util.FileUtil; import junit.framework.Test; +import static org.aspectj.util.LangUtil.is16VMOrGreater; + /** * @author Alexandre Vasseur */ @@ -133,11 +135,21 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase { // The working directory is different because this test must be forked File dir = new File("../tests/java5/ataspectj"); - File f = new File(dir, "_ajdump/_before/com/sun/proxy"); + + // Before Java 16, JDK proxies were given a virtual package name of 'com.sun.proxy'. Now the packages are numbered + // 'jdk.proxy[n]', i.e. 'jdk.proxy1', 'jdk.proxy2' etc. This makes the package-name-derived path name here less + // predictable. In our simple runtime scenario, we can be pretty sure than the counter starts at 1 because + // it is the first and only proxy we create. + // + // TODO: A better solution would be a recursive filtered search via Files.walk, ideally added as a recursive search + // option for CountingFilenameFilter. + String proxyDir = is16VMOrGreater() ? "jdk/proxy1" : "com/sun/proxy"; + + File f = new File(dir, "_ajdump/_before/" + proxyDir); CountingFilenameFilter cff = new CountingFilenameFilter(".class"); f.listFiles(cff); assertEquals("Expected dump file in " + f.getAbsolutePath(), 1, cff.getCount()); - f = new File(dir, "_ajdump/com/sun/proxy"); + f = new File(dir, "_ajdump/" + proxyDir); cff = new CountingFilenameFilter(".class"); f.listFiles(cff); assertEquals(1, cff.getCount()); -- 2.39.5