From 4471ba76ac755b504d99e514a1cf5a375e7d02d1 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 20 Apr 2020 16:24:02 -0700 Subject: Include JDTCore for Java14 --- util/src/main/java/org/aspectj/util/LangUtil.java | 17 +++-- .../test/java/org/aspectj/util/LangUtilTest.java | 78 +++++++++++----------- 2 files changed, 49 insertions(+), 46 deletions(-) (limited to 'util/src') diff --git a/util/src/main/java/org/aspectj/util/LangUtil.java b/util/src/main/java/org/aspectj/util/LangUtil.java index 50c5a78c0..a0967cfcc 100644 --- a/util/src/main/java/org/aspectj/util/LangUtil.java +++ b/util/src/main/java/org/aspectj/util/LangUtil.java @@ -84,7 +84,7 @@ public class LangUtil { if (vm == null) { new RuntimeException( "System properties appear damaged, cannot find: java.version/java.runtime.version/java.vm.version") - .printStackTrace(System.err); + .printStackTrace(System.err); vmVersion = 1.5; } else { // Version: [1-9][0-9]*((\.0)*\.[1-9][0-9]*)* @@ -107,7 +107,7 @@ public class LangUtil { } catch (Throwable t) { new RuntimeException( "System properties appear damaged, cannot find: java.version/java.runtime.version/java.vm.version", t) - .printStackTrace(System.err); + .printStackTrace(System.err); vmVersion = 1.5; } } @@ -129,7 +129,7 @@ public class LangUtil { return 1.3 <= vmVersion; } - public static boolean is14VMOrGreater() { + public static boolean is1dot4VMOrGreater() { return 1.4 <= vmVersion; } @@ -169,6 +169,9 @@ public class LangUtil { return 13 <= vmVersion; } + public static boolean is14VMOrGreater() { + return 14 <= vmVersion; + } /** * Shorthand for "if null, throw IllegalArgumentException" @@ -1001,7 +1004,7 @@ public class LangUtil { public static class StringChecker { static StringChecker TEST_PACKAGES = new StringChecker(new String[] { "org.aspectj.testing", "org.eclipse.jdt.internal.junit", "junit.framework.", - "org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" }); + "org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" }); String[] infixes; @@ -1123,8 +1126,8 @@ public class LangUtil { File binDir = new File(javaHome, "bin"); if (binDir.isDirectory() && binDir.canRead()) { String[] execs = new String[] { "java", "java.exe" }; - for (int i = 0; i < execs.length; i++) { - result = new File(binDir, execs[i]); + for (String exec : execs) { + result = new File(binDir, exec); if (result.canRead()) { break; } @@ -1514,7 +1517,7 @@ public class LangUtil { } public static String getJavaHome() { - return System.getProperty("java.home"); + return System.getProperty("java.home"); } } diff --git a/util/src/test/java/org/aspectj/util/LangUtilTest.java b/util/src/test/java/org/aspectj/util/LangUtilTest.java index f06103fec..7e95858b9 100644 --- a/util/src/test/java/org/aspectj/util/LangUtilTest.java +++ b/util/src/test/java/org/aspectj/util/LangUtilTest.java @@ -1,14 +1,14 @@ /* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, + * Copyright (c) 1999-2001 Xerox Corporation, * 2002 Palo Alto Research Center, Incorporated (PARC). - * 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://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation + * 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Xerox/PARC initial implementation * ******************************************************************/ package org.aspectj.util; @@ -19,7 +19,7 @@ import java.util.List; import junit.framework.TestCase; /** - * + * */ public class LangUtilTest extends TestCase { @@ -40,7 +40,7 @@ public class LangUtilTest extends TestCase { // EXP = "[-d, classes, -classpath, foo.jar, -verbose]"; // resultString = "" + extracted; // assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); - // + // // // no input, no output // extracted.clear(); // args = new String[] {}; @@ -50,7 +50,7 @@ public class LangUtilTest extends TestCase { // assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); // resultString = "" + extracted; // assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); - // + // // // one input, nothing extracted // extracted.clear(); // args = new String[] {"Bar.java"}; @@ -61,7 +61,7 @@ public class LangUtilTest extends TestCase { // EXP = "[]"; // resultString = "" + extracted; // assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); - // + // // // one input, extracted // extracted.clear(); // args = new String[] {"-verbose"}; @@ -87,7 +87,7 @@ public class LangUtilTest extends TestCase { // EXP = "[-verbose]"; // resultString = "" + extracted; // assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); - // + // // // one input, not extracted // extracted.clear(); // args = new String[] {"Bar.java"}; @@ -103,7 +103,7 @@ public class LangUtilTest extends TestCase { public void testVersion() { assertTrue(LangUtil.isOnePointThreeVMOrGreater()); // min vm now - floor may change if (LangUtil.is15VMOrGreater()) { - assertTrue(LangUtil.is14VMOrGreater()); + assertTrue(LangUtil.is1dot4VMOrGreater()); } } @@ -111,33 +111,33 @@ public class LangUtilTest extends TestCase { public void testExtractOptionsArrayCollector() { String[] args = new String[] { "-d", "classes", "-classpath", "foo.jar", "-verbose", "Bar.java" }; String[][] OPTIONS = new String[][] { new String[] { "-classpath", null }, new String[] { "-d", null }, - new String[] { "-verbose" }, new String[] { "-help" } }; + new String[] { "-verbose" }, new String[] { "-help" } }; - String[][] options = LangUtil.copyStrings(OPTIONS); + String[][] options = LangUtil.copyStrings(OPTIONS); - String[] result = LangUtil.extractOptions(args, options); - String resultString = "" + Arrays.asList(result); - String EXP = "[Bar.java]"; - assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); - assertTrue("-verbose".equals(options[2][0])); - assertTrue("foo.jar".equals(options[0][1])); - assertTrue("classes".equals(options[1][1])); - assertTrue("-classpath".equals(options[0][0])); - assertTrue("-d".equals(options[1][0])); - assertTrue(null == options[3][0]); + String[] result = LangUtil.extractOptions(args, options); + String resultString = "" + Arrays.asList(result); + String EXP = "[Bar.java]"; + assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); + assertTrue("-verbose".equals(options[2][0])); + assertTrue("foo.jar".equals(options[0][1])); + assertTrue("classes".equals(options[1][1])); + assertTrue("-classpath".equals(options[0][0])); + assertTrue("-d".equals(options[1][0])); + assertTrue(null == options[3][0]); - // get args back, no options set - args = new String[] { "Bar.java" }; - options = LangUtil.copyStrings(OPTIONS); + // get args back, no options set + args = new String[] { "Bar.java" }; + options = LangUtil.copyStrings(OPTIONS); - result = LangUtil.extractOptions(args, options); - resultString = "" + Arrays.asList(result); - EXP = "[Bar.java]"; - assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); - assertTrue(null == options[0][0]); - assertTrue(null == options[1][0]); - assertTrue(null == options[2][0]); - assertTrue(null == options[3][0]); + result = LangUtil.extractOptions(args, options); + resultString = "" + Arrays.asList(result); + EXP = "[Bar.java]"; + assertTrue(resultString + " != " + EXP, resultString.equals(EXP)); + assertTrue(null == options[0][0]); + assertTrue(null == options[1][0]); + assertTrue(null == options[2][0]); + assertTrue(null == options[3][0]); } // public void testOptionVariants() { @@ -153,7 +153,7 @@ public class LangUtilTest extends TestCase { // String[] threeB = new String[] {"-1-", "-2-", "-3-"}; // String[] athreeB = new String[] {"a", "-1-", "-2-", "-3-"}; // String[] threeaB = new String[] {"-1-", "a", "-2-", "-3-"}; - // + // // checkOptionVariants(NONE, new String[][] { NONE }); // checkOptionVariants(one, new String[][] { one }); // checkOptionVariants(both, new String[][] { both }); -- cgit v1.2.3