8304846: Provide a shared utility to dump generated classes defined via Lookup API

Reviewed-by: jvernee
This commit is contained in:
Mandy Chung 2023-04-04 18:07:02 +00:00
parent 2ee4245105
commit dd59471798
11 changed files with 440 additions and 393 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -1101,8 +1101,9 @@ abstract class MethodHandleImpl {
// use the original class name
name = name.replace('/', '_');
}
name = name.replace('.', '/');
Class<?> invokerClass = new Lookup(targetClass)
.makeHiddenClassDefiner(name, INJECTED_INVOKER_TEMPLATE, Set.of(NESTMATE))
.makeHiddenClassDefiner(name, INJECTED_INVOKER_TEMPLATE, Set.of(NESTMATE), dumper())
.defineClass(true, targetClass);
assert checkInjectedInvoker(targetClass, invokerClass);
return invokerClass;
@ -1655,12 +1656,6 @@ abstract class MethodHandleImpl {
return BindCaller.reflectiveInvoker(caller);
}
@Override
public Lookup defineHiddenClassWithClassData(Lookup caller, String name, byte[] bytes, Object classData, boolean initialize) {
// skip name and access flags validation
return caller.makeHiddenClassDefiner(name, bytes, Set.of()).defineClassAsLookup(initialize, classData);
}
@Override
public Class<?>[] exceptionTypes(MethodHandle handle) {
return VarHandles.exceptionTypes(handle);