changeset 14497:7a2e220a737d

8156972: java/lang/reflect/Layer/LayerAndLoadersTest.java test requires jdk.compiler Reviewed-by: alanb Contributed-by: alexandre.iline@oracle.com
author alanb
date Wed, 18 May 2016 11:56:24 +0100
parents 3bf3f8ac5f37
children 5f52de8fe40c
files test/java/lang/reflect/Layer/LayerAndLoadersTest.java test/lib/testlibrary/CompilerUtils.java
diffstat 2 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/lang/reflect/Layer/LayerAndLoadersTest.java	Wed May 18 15:03:39 2016 +0530
+++ b/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/test/lib/testlibrary/CompilerUtils.java	Wed May 18 15:03:39 2016 +0530
+++ b/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