aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-19 01:16:39 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2021-03-19 02:14:24 +0100
commit6723525c4a1ba368b6f7c6a58ddd6b15fc77c3aa (patch)
treeac5acf935a08319796a3e781836405d0022d4777 /test
parentcbf930a9b8245aab402f68e1b0acbb948cd78d8f (diff)
downloadlombok-6723525c4a1ba368b6f7c6a58ddd6b15fc77c3aa.tar.gz
lombok-6723525c4a1ba368b6f7c6a58ddd6b15fc77c3aa.tar.bz2
lombok-6723525c4a1ba368b6f7c6a58ddd6b15fc77c3aa.zip
[testing] unbroke 'ant test.javac8'.
Diffstat (limited to 'test')
-rw-r--r--test/bytecode/src/lombok/bytecode/TestClassFileMetaData.java24
1 files changed, 19 insertions, 5 deletions
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());