< prev index next >

src/java.base/share/classes/jdk/internal/misc/PreviewFeatures.java

Print this page

20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 package jdk.internal.misc;
26 
27 /**
28  * Defines static methods to test if preview features are enabled at run-time.
29  */
30 public class PreviewFeatures {
31     private static final boolean ENABLED = isPreviewEnabled();
32 
33     private PreviewFeatures() {
34     }
35 
36     /**
37      * {@return true if preview features are enabled, otherwise false}
38      */
39     public static boolean isEnabled() {
40         return ENABLED;
41     }
42 
43     /**
44      * Ensures that preview features are enabled.
45      * @throws UnsupportedOperationException if preview features are not enabled
46      */
47     public static void ensureEnabled() {
48         if (!isEnabled()) {
49             throw new UnsupportedOperationException(
50                 "Preview Features not enabled, need to run with --enable-preview");
51         }
52     }
53 
54     private static native boolean isPreviewEnabled();
55 }

20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 package jdk.internal.misc;
26 
27 /**
28  * Defines static methods to test if preview features are enabled at run-time.
29  */
30 public class PreviewFeatures {
31     private static final boolean ENABLED = isPreviewEnabled();
32 
33     private PreviewFeatures() {
34     }
35 
36     /**
37      * {@return true if preview features are enabled, otherwise false}
38      */
39     public static boolean isEnabled() {
40         return true; // FIXME: return true until test environment ready
41     }
42 
43     /**
44      * Ensures that preview features are enabled.
45      * @throws UnsupportedOperationException if preview features are not enabled
46      */
47     public static void ensureEnabled() {
48         if (!isEnabled()) {
49             throw new UnsupportedOperationException(
50                 "Preview Features not enabled, need to run with --enable-preview");
51         }
52     }
53 
54     private static native boolean isPreviewEnabled();
55 }
< prev index next >