Skip to content

Commit d009eaa

Browse files
add system property guard to preview mode
1 parent 8858134 commit d009eaa

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/java.base/share/classes/jdk/internal/jimage/PreviewMode.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ boolean resolve() {
5353
ENABLED() {
5454
@Override
5555
boolean resolve() {
56-
return true;
56+
return ENABLE_PREVIEW_MODE;
5757
}
5858
},
5959
/**
@@ -63,6 +63,9 @@ boolean resolve() {
6363
FOR_RUNTIME() {
6464
@Override
6565
boolean resolve() {
66+
if (!ENABLE_PREVIEW_MODE) {
67+
return false;
68+
}
6669
// We want to call jdk.internal.misc.PreviewFeatures.isEnabled(), but
6770
// is not available in older JREs, so we must look to it reflectively.
6871
Class<?> clazz;
@@ -81,6 +84,15 @@ boolean resolve() {
8184
}
8285
};
8386

87+
// Temporary system property to disable preview patching and enable the new preview mode
88+
// feature for testing/development. Once the preview mode feature is finished, the value
89+
// will be always 'true' and this code, and all related dead-code can be removed.
90+
private static final boolean DISABLE_PREVIEW_PATCHING_DEFAULT = false;
91+
private static final boolean ENABLE_PREVIEW_MODE = Boolean.parseBoolean(
92+
System.getProperty(
93+
"DISABLE_PREVIEW_PATCHING",
94+
Boolean.toString(DISABLE_PREVIEW_PATCHING_DEFAULT)));
95+
8496
/**
8597
* Resolves whether preview mode should be enabled for an {@link ImageReader}.
8698
*/

0 commit comments

Comments
 (0)