8156972: java/lang/reflect/Layer/LayerAndLoadersTest.java test requires jdk.compiler
authoralanb
Wed, 18 May 2016 11:56:24 +0100
changeset 38378 3ae899b05d36
parent 38377 f5b2f9c076ef
child 38379 e2262f30140a
8156972: java/lang/reflect/Layer/LayerAndLoadersTest.java test requires jdk.compiler Reviewed-by: alanb Contributed-by: alexandre.iline@oracle.com
jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java
jdk/test/lib/testlibrary/CompilerUtils.java
--- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Wed May 18 15:03:39 2016 +0530
+++ b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Wed May 18 11:56:24 2016 +0100
@@ -24,6 +24,7 @@
 /**
  * @test
  * @library /lib/testlibrary
+ * @modules jdk.compiler
  * @build LayerAndLoadersTest CompilerUtils ModuleUtils
  * @run testng LayerAndLoadersTest
  * @summary Tests for java.lang.reflect.Layer@createWithXXX methods
--- a/jdk/test/lib/testlibrary/CompilerUtils.java	Wed May 18 15:03:39 2016 +0530
+++ b/jdk/test/lib/testlibrary/CompilerUtils.java	Wed May 18 11:56:24 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,13 +50,21 @@
      *
      * @return true if the compilation is successful
      *
-     * @throws IOException if there is an I/O error scanning the source tree or
-     *                     creating the destination directory
+     * @throws IOException
+     *         if there is an I/O error scanning the source tree or
+     *         creating the destination directory
+     * @throws UnsupportedOperationException
+     *         if there is no system java compiler
      */
     public static boolean compile(Path source, Path destination, String ... options)
         throws IOException
     {
         JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            // no compiler available
+            throw new UnsupportedOperationException("Unable to get system java compiler. " +
+                "Perhaps, jdk.compiler module is not available.");
+        }
         StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
 
         List<Path> sources