diff options
-rw-r--r-- | buildScripts/compile.ant.xml | 2 | ||||
-rw-r--r-- | buildScripts/tests.ant.xml | 2 | ||||
-rw-r--r-- | test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java | 24 |
3 files changed, 22 insertions, 6 deletions
diff --git a/buildScripts/compile.ant.xml b/buildScripts/compile.ant.xml index 00909db8..cd0672b5 100644 --- a/buildScripts/compile.ant.xml +++ b/buildScripts/compile.ant.xml @@ -50,7 +50,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and buil <echo level="info">Lombok version: ${lombok.version} (${lombok.fullversion})</echo> </target> - <property name="packing.basedirs" value="build/lombok-transplants,build/lombok-utils,build/lombok-utils6,build/lombok-main,build/lombok-main8,build/lombok-deps" /> + <property name="packing.basedirs" value="build/lombok-transplants,build/lombok-utils,build/lombok-utils6,build/lombok-main,build/lombok-main8" /> <loadresource property="packing.basedirs.colon"> <propertyresource name="packing.basedirs" /> <filterchain><tokenfilter> diff --git a/buildScripts/tests.ant.xml b/buildScripts/tests.ant.xml index f250b340..079ec85a 100644 --- a/buildScripts/tests.ant.xml +++ b/buildScripts/tests.ant.xml @@ -88,6 +88,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <classpath refid="cp.javac6" /> <classpath refid="packing.basedirs.path" /> <classpath location="build/tests" /> + <classpath location="build/teststubs" /> <test name="lombok.TestJavac" /> </junit> </target> @@ -105,6 +106,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <classpath refid="cp.javac8" /> <classpath refid="packing.basedirs.path" /> <classpath location="build/tests" /> + <classpath location="build/teststubs" /> <test name="lombok.TestJavac" /> </junit> </target> diff --git a/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java b/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java index 5ff7e93b..7aef0d51 100644 --- a/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java +++ b/test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 The Project Lombok Authors. + * Copyright (C) 2010-2021 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -56,7 +56,7 @@ public class TestClassFileMetaData { public void testGetClassName() { assertTrue(foo.containsUtf8("Foo")); assertEquals("Foo", foo.getClassName()); - + assertTrue(bar.containsUtf8("Bar")); assertEquals("Bar", bar.getClassName()); @@ -68,15 +68,13 @@ public class TestClassFileMetaData { public void testGetSuperClassName() { assertTrue(foo.containsUtf8("java/lang/Object")); assertEquals("java/lang/Object", foo.getSuperClassName()); - + assertEquals("java/lang/Object", bar.getSuperClassName()); assertEquals("java/lang/Object", baz.getSuperClassName()); assertEquals("java/util/ArrayList", buux.getSuperClassName()); } - - @Test public void testUsesClass() { assertTrue(foo.usesClass("java/lang/System")); @@ -185,6 +183,22 @@ public class TestClassFileMetaData { static byte[] compile(File file) { try { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + if (compiler == null) { + // The 'auto-find my compiler' code in java6 works because it hard-codes `c.s.t.j.a.JavacTool`, which we put on the classpath. + // On java8, it fails, because it looks for tools.jar, which won't be there. + // on J11+ place it succeeds again, as we run those on the real JDKs. + + // Thus, let's try this, in cae we're on java 8: + + try { + compiler = (JavaCompiler) Class.forName("com.sun.tools.javac.api.JavacTool").getConstructor().newInstance(); + } catch (Exception e) { + compiler = null; + } + } + + if (compiler == null) throw new RuntimeException("No javac tool is available in this distribution. Using an old JRE perhaps?"); + File tempDir = getTempDir(); tempDir.mkdirs(); List<String> options = Arrays.asList("-proc:none", "-d", tempDir.getAbsolutePath()); |