--- old/test/jdk/jdk/jfr/event/runtime/TestClasses.java 2020-03-26 16:01:59.000000000 -0700 +++ new/test/jdk/jdk/jfr/event/runtime/TestClasses.java 2020-03-26 16:01:58.000000000 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,6 +25,14 @@ package jdk.jfr.event.runtime; +import java.lang.invoke.MethodType; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; +import java.lang.reflect.Array; +import static java.lang.invoke.MethodHandles.Lookup.ClassOption.*; + +import jdk.internal.misc.Unsafe; + public class TestClasses { protected TestClassPrivate testClassPrivate; @@ -76,8 +84,20 @@ class TestClass { static { - // force creation of anonymous class (for the lambda form) + // force creation of hidden class (for the lambda form) Runnable r = () -> System.out.println("Hello"); r.run(); } + + public static void createNonFindableClasses(byte[] klassbuf) throws Throwable { + // Create a hidden class and an array of hidden classes. + Lookup lookup = MethodHandles.lookup(); + Class clh = lookup.defineHiddenClass(klassbuf, false, NESTMATE).lookupClass(); + Class arrayOfHidden = Array.newInstance(clh, 10).getClass(); // HAS ISSUES? + + // Create an Unsafe anonymous class and an array of unsafe anonymous classes. + Unsafe unsafe = Unsafe.getUnsafe(); + Class clu = unsafe.defineAnonymousClass(TestClass.class, klassbuf, new Object[0]); + final Class arrayOfUAC = Array.newInstance(clu, 15).getClass(); + } }