Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes based on late comments concerning 8247795 fix #99

wants to merge 1 commit into from
Changes from all commits
File filter

Filter by extension

Filter by extension

Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -2479,9 +2479,12 @@ Method* ClassFileParser::parse_method(const ClassFileStream* const cfs,
if (ss.is_reference()) {
Symbol* ret = ss.as_symbol();
const Symbol* required = class_name();
if (is_hidden() || is_unsafe_anonymous()) {
// The original class name in hidden classes and in the UAC byte stream gets
// changed. So using the original name in the return type is no longer valid.
if (is_hidden()) {
// The original class name in hidden classes gets changed. So using
// the original name in the return type is no longer valid.
// Note that expecting the return type for inline hidden class factory
// methods to be java.lang.Object works around a JVM Spec issue for
// hidden classes.
required = vmSymbols::java_lang_Object();
ok = (ret == required);
@@ -912,6 +912,8 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na
// Note the cast (Object), which tells the verifier to expect an arbitrary object,
// not just a literal string. For such ldc instructions, the verifier uses the
// type Object instead of String, if the loaded constant is not in fact a String.
// An anonymous class cannot be an inline type.

static InstanceKlass*
Unsafe_DefineAnonymousClass_impl(JNIEnv *env,
@@ -1007,6 +1009,8 @@ Unsafe_DefineAnonymousClass_impl(JNIEnv *env,
return NULL;

assert(!anonk->is_inline_klass(), "unsafe anonymous class cannot be inline class");

return InstanceKlass::cast(anonk);

@@ -1223,7 +1223,7 @@ oop Reflection::invoke_constructor(oop constructor_mirror, objArrayHandle args,
assert(klass->is_inline_klass(), "inline classes must use factory methods");
Handle no_receiver; // null instead of receiver
BasicType rtype;
if (klass->is_hidden() || klass->is_unsafe_anonymous()) {
if (klass->is_hidden()) {
rtype = T_OBJECT;
} else {
rtype = T_VALUETYPE;
@@ -30,38 +30,30 @@
* @run main HiddenInlineClassTest

import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import static java.lang.invoke.MethodHandles.Lookup.ClassOption.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class HiddenInlineClassTest {

static final Path CLASSES_DIR = Paths.get(System.getProperty("test.classes"));
static final Path CLASSES_DIR = Paths.get(System.getProperty("test.classes", "."));
String hello = "hello";

static byte[] readClassFile(String classFileName) throws Exception {
File classFile = new File(CLASSES_DIR + File.separator + classFileName);
try (FileInputStream in = new FileInputStream(classFile);
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
int b;
while ((b = != -1) {
return out.toByteArray();
Path path = CLASSES_DIR.resolve(classFileName.replace('.', File.separatorChar) + ".class");
return Files.readAllBytes(path);

public static void main(String[] args) throws Throwable {
Lookup lookup = MethodHandles.lookup();
byte[] bytes = readClassFile("HiddenPoint.class");
byte[] bytes = readClassFile("HiddenPoint");

// Define a hidden class that is an inline type.
Class<?> c = lookup.defineHiddenClass(bytes, true, NESTMATE).lookupClass();
Class<?> c = lookup.defineHiddenClass(bytes, true).lookupClass();
Object hp = c.newInstance();
String s = (String)c.getMethod("getValue").invoke(hp);
if (!s.equals("x: 0, y: 0")) {