< prev index next > test/jdk/java/lang/Class/getModifiers/TestPrimitiveAndArrayModifiers.java
Print this page
/*
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2022, 2026, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+ import jdk.internal.misc.PreviewFeatures;
+
+ import java.lang.classfile.ClassFile;
import java.lang.reflect.Modifier;
import java.lang.annotation.*;
/*
* @test
* @bug 8296743
+ * @modules java.base/jdk.internal.misc
* @summary Verify array classes and primitives have expected modifiers
+ * @run main/othervm TestPrimitiveAndArrayModifiers
+ * @run main/othervm --enable-preview TestPrimitiveAndArrayModifiers
*/
@ExpectedModifiers(Modifier.PUBLIC | Modifier.FINAL | Modifier.ABSTRACT)
public class TestPrimitiveAndArrayModifiers {
/*
};
for(var testCase : testCases) {
int expectedModifiers =
testCase.getAnnotation(ExpectedModifiers.class).value();
+ if (PreviewFeatures.isEnabled()) {
+ // All arrays under preview also have IDENTITY
+ expectedModifiers |= ClassFile.ACC_IDENTITY;
+ }
Class<?> arrayClass = testCase.arrayType();
int actualModifiers = arrayClass.getModifiers();
if (expectedModifiers != actualModifiers) {
throw new RuntimeException("Expected " + Modifier.toString(expectedModifiers) +
- "on " + testCase.getCanonicalName() +
+ " on " + testCase.getCanonicalName() +
", but got " + Modifier.toString(actualModifiers));
}
}
}
< prev index next >