hg: jdk8/tl/jdk: 7194897: JSR 292: Cannot create more than 16 instances of an anonymous class; ...
Joel Borggren-Franck
joel.franck at oracle.com
Mon Nov 25 14:57:51 UTC 2013
Hi Peter,
I filed: https://bugs.openjdk.java.net/browse/JDK-8029100
Thanks!
cheers
/Joel
On 2013-11-05, Peter Levart wrote:
> Hi John,
>
> Speaking of names, the following test:
>
> package pkg;
>
> public class Test {
> public static void main(String[] args)
> {
> Runnable r = () -> {};
> Class<?> c = r.getClass();
> Class<?> ac = java.lang.reflect.Array.newInstance(c, 0).getClass();
> System.out.println("c: " + c.getName() + " / " +
> c.getSimpleName());
> System.out.println("ac: " + ac.getName() + " / " +
> ac.getSimpleName());
> }
> }
>
>
> Prints:
>
> c: pkg.Test$$Lambda$1/798154996 / Test$$Lambda$1/798154996
> ac: [Lpkg.Test$$Lambda$1; / Test$$Lambda$1/798154996[]
>
>
> I think the array class name is missing the trailing '/798154996'
> just before ';'
>
>
> Regards, Peter
>
> On 11/05/2013 09:55 AM, Peter Levart wrote:
> >On 11/04/2013 07:12 PM, robert.field at oracle.com wrote:
> >>Changeset: 51b002381b35
> >>Author: rfield
> >>Date: 2013-11-04 10:12 -0800
> >>URL:http://hg.openjdk.java.net/jdk8/tl/jdk/rev/51b002381b35
> >>
> >>7194897: JSR 292: Cannot create more than 16 instances of an anonymous class
> >>8027681: Lambda serialization fails once reflection proxy generation kicks in
> >>Reviewed-by: ksrini, briangoetz, jfranck
> >>Contributed-by:joel.franck at oracle.com,brian.goetz at oracle.com,robert.field at oracle.com
> >>
> >>! src/share/classes/sun/reflect/NativeConstructorAccessorImpl.java
> >>! src/share/classes/sun/reflect/NativeMethodAccessorImpl.java
> >>! src/share/classes/sun/reflect/misc/ReflectUtil.java
> >>+ test/java/lang/invoke/lambda/RepetitiveLambdaSerialization.java
> >>! test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
> >>+ test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java
> >>
> >Hi Robert,
> >
> >I also propose a much faster variant of:
> >
> >+ /**
> >+ * Checks if {@code Class cls} is a VM-anonymous class
> >+ * as defined by {@link sun.misc.Unsafe#defineAnonymousClass}
> >+ * (not to be confused with a Java Language anonymous inner class).
> >+ */
> >+ public static boolean isVMAnonymousClass(Class<?> cls) {
> >+ return cls.getSimpleName().contains("/");
> >+ }
> >
> >
> >The following:
> >
> > public static boolean isVMAnonymousClassFAST(Class<?> cls) {
> > String name = cls.getName();
> > for (int i = name.length() - 1; i >= 0; i--) {
> > char c = name.charAt(i);
> > if (c == '.') return false;
> > if (c == '/') return true;
> > }
> > return false; // root package
> > }
> >
> >It's about 12..25x faster for typical class names and doesn't
> >produce any garbage.
> >
> >
> >Regards, Peter
> >
>
More information about the core-libs-dev
mailing list