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

8245216: [lworld] The JVM should inject the IdentityObject interface to types which need it #51

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/hotspot/share/classfile/verificationType.cpp
Original file line number Diff line number Diff line change
@@ -60,7 +60,8 @@ bool VerificationType::resolve_and_check_assignability(InstanceKlass* klass, Sym
from_name != vmSymbols::java_lang_Object())) {
// If we are not trying to access a protected field or method in
// java.lang.Object then, for arrays, we only allow assignability
// to interfaces java.lang.Cloneable and java.io.Serializable.
// to interfaces java.lang.Cloneable, java.io.Serializable,
// and java.lang.IdentityObject.
// Otherwise, we treat interfaces as java.lang.Object.
return !from_is_array ||
this_class == SystemDictionary::Cloneable_klass() ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the comment at line 63 to include java.lang.IdentityObject?

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@@ -79,10 +79,12 @@ public class ClassHierarchyTest {
Pattern.compile("java.lang.Object/null"),
Pattern.compile("\\|--DcmdBaseClass/0x(\\p{XDigit}*)"),
Pattern.compile("\\| implements Intf2/0x(\\p{XDigit}*) \\(declared intf\\)"),
Pattern.compile("\\| implements java.lang.IdentityObject/null \\(declared intf\\)"),
Pattern.compile("\\| implements Intf1/0x(\\p{XDigit}*) \\(inherited intf\\)"),
Pattern.compile("\\| \\|--DcmdTestClass/0x(\\p{XDigit}*)"),
Pattern.compile("\\| \\| implements Intf1/0x(\\p{XDigit}*) \\(inherited intf\\)"),
Pattern.compile("\\| \\| implements Intf2/0x(\\p{XDigit}*) \\(inherited intf\\)")
Pattern.compile("\\| \\| implements Intf2/0x(\\p{XDigit}*) \\(inherited intf\\)"),
Pattern.compile("\\| \\| implements java.lang.IdentityObject/null \\(inherited intf\\)")
};

public void run(CommandExecutor executor) throws ClassNotFoundException {
@@ -140,7 +142,7 @@ public void run(CommandExecutor executor) throws ClassNotFoundException {
Assert.fail("Failed to match line #" + i + ": " + line);
}
// "implements" lines should not be in this output.
if (i == 2 || i == 4) i += 2;
if (i == 2 || i == 6) i += 3;
}
if (lines.hasNext()) {
String line = lines.next();
@@ -164,7 +166,7 @@ public void run(CommandExecutor executor) throws ClassNotFoundException {
// subsequent lines.
classLoaderAddr = m.group(1);
System.out.println(classLoaderAddr);
} else if (i > 2) {
} else if (i > 2 && i != 4 && i != 9) {
if (!classLoaderAddr.equals(m.group(1))) {
Assert.fail("Classloader address didn't match on line #"
+ i + ": " + line);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, 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,6 +50,7 @@ public class interfaces001 {
};
static final int DECLARED_INTERFACES = class_interfaces.length;
static final long interfaceIDs[] = new long[DECLARED_INTERFACES];
static long identityObjectID;

public static void main (String argv[]) {
System.exit(run(argv,System.out) + JCK_STATUS_BASE);
@@ -98,6 +99,7 @@ public int runIt(String argv[], PrintStream out) {
log.display("Getting ReferenceTypeID for interface signature: " + class_interfaces[i][1]);
interfaceIDs[i] = debugee.getReferenceTypeID(class_interfaces[i][1]);
}
identityObjectID = debugee.getReferenceTypeID("Ljava/lang/IdentityObject;");

// begin test of JDWP command

@@ -124,7 +126,8 @@ public int runIt(String argv[], PrintStream out) {
int interfaces = reply.getInt();
log.display(" interfaces: " + interfaces);

if (interfaces != DECLARED_INTERFACES) {
// Adding one to the number of interfaces because of the injection of IdentityObject by the VM
if (interfaces != DECLARED_INTERFACES + 1) {
log.complain("Unexpected number of declared interfaces in the reply packet:" + interfaces
+ " (expected: " + DECLARED_INTERFACES + ")");
success = false;
@@ -137,12 +140,19 @@ public int runIt(String argv[], PrintStream out) {
long interfaceID = reply.getReferenceTypeID();
log.display(" interfaceID: " + interfaceID);

if (interfaceID != interfaceIDs[i]) {
log.complain("Unexpected interface ID for interface #" + i + " in the reply packet: " + interfaceID
+ " (expected: " + interfaceIDs[i] + ")");
success = false;
if (i < DECLARED_INTERFACES) {
if (interfaceID != interfaceIDs[i]) {
log.complain("Unexpected interface ID for interface #" + i + " in the reply packet: " + interfaceID
+ " (expected: " + interfaceIDs[i] + ")");
success = false;
}
} else {
if (interfaceID != identityObjectID) {
log.complain("Unexpected interface ID for interface #" + i + " in the reply packet: " + interfaceID
+ " (expected identityObjectID: " + identityObjectID + ")");
success = false;
}
}

}

if (! reply.isParsed()) {