Skip to content

Commit

Permalink
6983726: Reimplement MethodHandleProxies.asInterfaceInstance
Browse files Browse the repository at this point in the history
Co-authored-by: Mandy Chung <mchung@openjdk.org>
Reviewed-by: jvernee, mchung
  • Loading branch information
liach and Mandy Chung committed Jul 20, 2023
1 parent 71cac8c commit 5d57b5c
Show file tree
Hide file tree
Showing 13 changed files with 1,149 additions and 401 deletions.
7 changes: 5 additions & 2 deletions src/hotspot/share/prims/jvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,11 @@ static jclass jvm_lookup_define_class(jclass lookup, const char *name,
ik->is_hidden() ? "is hidden" : "is not hidden");
}
}
assert(Reflection::is_same_class_package(lookup_k, ik),
"lookup class and defined class are in different packages");

if ((!is_hidden || is_nestmate) && !Reflection::is_same_class_package(lookup_k, ik)) {
// non-hidden class or nestmate class must be in the same package as the Lookup class
THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Lookup class and defined class are in different packages");
}

if (init) {
ik->initialize(CHECK_NULL);
Expand Down
549 changes: 423 additions & 126 deletions src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions src/java.base/share/classes/java/lang/reflect/ReflectAccess.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2023, 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
Expand Down Expand Up @@ -94,6 +94,10 @@ public Class<?>[] getExecutableSharedParameterTypes(Executable ex) {
return ex.getSharedParameterTypes();
}

public Class<?>[] getExecutableSharedExceptionTypes(Executable ex) {
return ex.getSharedExceptionTypes();
}

//
// Copying routines, needed to quickly fabricate new Field,
// Method, and Constructor objects from templates
Expand Down Expand Up @@ -127,9 +131,4 @@ public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller)
{
return ctor.newInstanceWithCaller(args, true, caller);
}

public Object invokeDefault(Object proxy, Method method, Object[] args, Class<?> caller)
throws Throwable {
return Proxy.invokeDefault(proxy, method, args, caller);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2023, 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
Expand Down Expand Up @@ -76,6 +76,9 @@ public void setConstructorAccessor(Constructor<?> c,
/** Gets the shared array of parameter types of an Executable. */
public Class<?>[] getExecutableSharedParameterTypes(Executable ex);

/** Gets the shared array of exception types of an Executable. */
public Class<?>[] getExecutableSharedExceptionTypes(Executable ex);

//
// Copying routines, needed to quickly fabricate new Field,
// Method, and Constructor objects from templates
Expand All @@ -102,11 +105,4 @@ public void setConstructorAccessor(Constructor<?> c,
/** Returns a new instance created by the given constructor with access check */
public <T> T newInstance(Constructor<T> ctor, Object[] args, Class<?> caller)
throws IllegalAccessException, InstantiationException, InvocationTargetException;

/** Invokes the given default method if the method's declaring interface is
* accessible to the given caller. Otherwise, IllegalAccessException will
* be thrown. If the caller is null, no access check is performed.
*/
public Object invokeDefault(Object proxy, Method method, Object[] args, Class<?> caller)
throws Throwable;
}
48 changes: 0 additions & 48 deletions src/java.base/share/classes/sun/invoke/WrapperInstance.java

This file was deleted.

1 comment on commit 5d57b5c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.