From max.kammerer at yahoo.com Mon Nov 14 09:58:47 2016 From: max.kammerer at yahoo.com (=?UTF-8?B?0JzQuNGF0LDQuNC7INCR0L7Qs9C00LDQvdC+0LI=?=) Date: Mon, 14 Nov 2016 09:58:47 +0000 (UTC) Subject: JDK 8 incorectly processes nameless parameters in MethodParameters Attribute References: <1032008483.3558155.1479117527023.ref@mail.yahoo.com> Message-ID: <1032008483.3558155.1479117527023@mail.yahoo.com> JDK 8 incorrectly processes nameless (name=null) parameters in MethodParameters attribute. Actually problem in inconsistency between Hotspot and reflection: Hotspot? VM constructs nameless parameter with empty string name that cause Executable.verifyParameters to throw MalformedParametersException. //Code to reproduce:import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.org.objectweb.asm.Opcodes; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; public class Bug { ??? public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException { ??????? ClassWriter writer = new ClassWriter(Opcodes.ASM5); ??????? writer.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT, "Test", null, "java/lang/Object", null); ??????? MethodVisitor test = writer.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, "test", "(I)V", null, null); ??????? test.visitParameter(null, 0); ??????? test.visitEnd(); ??????? writer.visitEnd(); ??????? final byte[] bytes = writer.toByteArray(); ??????? URLClassLoader urlClassLoader = new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader()) { ??????????? @Override ??????????? protected Class findClass(String name) throws ClassNotFoundException { ??????????????? if (name.equals("Test")) { ??????????????????? return defineClass("Test", bytes, 0, bytes.length); ??????????????? } ??????????????? return super.findClass(name); ??????????? } ??????? }; ??????? Class clazz = urlClassLoader.loadClass("Test"); ??????? Method method = clazz.getDeclaredMethod("test", Integer.TYPE); //??????? Exception in thread "main" java.lang.reflect.MalformedParametersException: Invalid parameter name "" //??????? at java.lang.reflect.Executable.verifyParameters(Executable.java:386) //??????? at java.lang.reflect.Executable.privateGetParameters(Executable.java:416) //??????? at java.lang.reflect.Executable.getParameters(Executable.java:357) //??????? at Bug.main(Bug.java:37) ??????? method.getParameters(); ??? } } Best regards,?? Max From dalibor.topic at oracle.com Fri Nov 18 10:29:14 2016 From: dalibor.topic at oracle.com (dalibor topic) Date: Fri, 18 Nov 2016 11:29:14 +0100 Subject: JDK 8 incorectly processes nameless parameters in MethodParameters Attribute In-Reply-To: <1032008483.3558155.1479117527023@mail.yahoo.com> References: <1032008483.3558155.1479117527023.ref@mail.yahoo.com> <1032008483.3558155.1479117527023@mail.yahoo.com> Message-ID: <320bfac3-3279-1e4d-2799-cc536506866c@oracle.com> Hi Mihail, could you file an issue at bugs.java.com and let us know which incident id you receive, please? cheers, dalibor topic On 14.11.2016 10:58, ?????? ???????? wrote: > JDK 8 incorrectly processes nameless (name=null) parameters in MethodParameters attribute. Actually problem in inconsistency between Hotspot and reflection: > Hotspot VM constructs nameless parameter with empty string name that cause Executable.verifyParameters to throw MalformedParametersException. > //Code to reproduce:import jdk.internal.org.objectweb.asm.ClassWriter; > import jdk.internal.org.objectweb.asm.MethodVisitor; > import jdk.internal.org.objectweb.asm.Opcodes; > > import java.lang.reflect.Method; > import java.net.URL; > import java.net.URLClassLoader; > > public class Bug { > > public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException { > ClassWriter writer = new ClassWriter(Opcodes.ASM5); > writer.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT, "Test", null, "java/lang/Object", null); > MethodVisitor test = writer.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, "test", "(I)V", null, null); > test.visitParameter(null, 0); > test.visitEnd(); > > writer.visitEnd(); > final byte[] bytes = writer.toByteArray(); > > URLClassLoader urlClassLoader = new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader()) { > @Override > protected Class findClass(String name) throws ClassNotFoundException { > if (name.equals("Test")) { > return defineClass("Test", bytes, 0, bytes.length); > } > return super.findClass(name); > } > }; > > > Class clazz = urlClassLoader.loadClass("Test"); > Method method = clazz.getDeclaredMethod("test", Integer.TYPE); > // Exception in thread "main" java.lang.reflect.MalformedParametersException: Invalid parameter name "" > // at java.lang.reflect.Executable.verifyParameters(Executable.java:386) > // at java.lang.reflect.Executable.privateGetParameters(Executable.java:416) > // at java.lang.reflect.Executable.getParameters(Executable.java:357) > // at Bug.main(Bug.java:37) > method.getParameters(); > } > } > Best regards, Max > -- Dalibor Topic | Principal Product Manager Phone: +494089091214 | Mobile: +491737185961 ORACLE Deutschland B.V. & Co. KG | K?hneh?fe 5 | 22761 Hamburg ORACLE Deutschland B.V. & Co. KG Hauptverwaltung: Riesstr. 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment From max.kammerer at yahoo.com Mon Nov 21 17:12:55 2016 From: max.kammerer at yahoo.com (=?UTF-8?B?0JzQuNGF0LDQuNC7INCR0L7Qs9C00LDQvdC+0LI=?=) Date: Mon, 21 Nov 2016 17:12:55 +0000 (UTC) Subject: =?UTF-8?Q?=D0=9E=D1=82=D0=B2:_JDK_8_incorectly_processes_nameless?= =?UTF-8?Q?_parameters_in=09MethodParameters_Attribute?= In-Reply-To: <320bfac3-3279-1e4d-2799-cc536506866c@oracle.com> References: <1032008483.3558155.1479117527023.ref@mail.yahoo.com> <1032008483.3558155.1479117527023@mail.yahoo.com> <320bfac3-3279-1e4d-2799-cc536506866c@oracle.com> Message-ID: <494816859.1314694.1479748375537@mail.yahoo.com> #9045294 ???????, 18 ?????? 2016 11:30 dalibor topic ?????(?): Hi Mihail, could you file an issue at bugs.java.com and let us know which incident id you receive, please? cheers, dalibor topic On 14.11.2016 10:58, ?????? ???????? wrote: > JDK 8 incorrectly processes nameless (name=null) parameters in MethodParameters attribute. Actually problem in inconsistency between Hotspot and reflection: > Hotspot? VM constructs nameless parameter with empty string name that cause Executable.verifyParameters to throw MalformedParametersException. > //Code to reproduce:import jdk.internal.org.objectweb.asm.ClassWriter; > import jdk.internal.org.objectweb.asm.MethodVisitor; > import jdk.internal.org.objectweb.asm.Opcodes; > > import java.lang.reflect.Method; > import java.net.URL; > import java.net.URLClassLoader; > > public class Bug { > >? ? public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException { >? ? ? ? ClassWriter writer = new ClassWriter(Opcodes.ASM5); >? ? ? ? writer.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT, "Test", null, "java/lang/Object", null); >? ? ? ? MethodVisitor test = writer.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_ABSTRACT, "test", "(I)V", null, null); >? ? ? ? test.visitParameter(null, 0); >? ? ? ? test.visitEnd(); > >? ? ? ? writer.visitEnd(); >? ? ? ? final byte[] bytes = writer.toByteArray(); > >? ? ? ? URLClassLoader urlClassLoader = new URLClassLoader(new URL[0], ClassLoader.getSystemClassLoader()) { >? ? ? ? ? ? @Override >? ? ? ? ? ? protected Class findClass(String name) throws ClassNotFoundException { >? ? ? ? ? ? ? ? if (name.equals("Test")) { >? ? ? ? ? ? ? ? ? ? return defineClass("Test", bytes, 0, bytes.length); >? ? ? ? ? ? ? ? } >? ? ? ? ? ? ? ? return super.findClass(name); >? ? ? ? ? ? } >? ? ? ? }; > > >? ? ? ? Class clazz = urlClassLoader.loadClass("Test"); >? ? ? ? Method method = clazz.getDeclaredMethod("test", Integer.TYPE); > //? ? ? ? Exception in thread "main" java.lang.reflect.MalformedParametersException: Invalid parameter name "" > //? ? ? ? at java.lang.reflect.Executable.verifyParameters(Executable.java:386) > //? ? ? ? at java.lang.reflect.Executable.privateGetParameters(Executable.java:416) > //? ? ? ? at java.lang.reflect.Executable.getParameters(Executable.java:357) > //? ? ? ? at Bug.main(Bug.java:37) >? ? ? ? method.getParameters(); >? ? } > } > Best regards,? Max > -- Dalibor Topic | Principal Product Manager Phone: +494089091214 | Mobile: +491737185961 ORACLE Deutschland B.V. & Co. KG | K?hneh?fe 5 | 22761 Hamburg ORACLE Deutschland B.V. & Co. KG Hauptverwaltung: Riesstr. 25, D-80992 M?nchen Registergericht: Amtsgericht M?nchen, HRA 95603 Komplement?rin: ORACLE Deutschland Verwaltung B.V. Hertogswetering 163/167, 3543 AS Utrecht, Niederlande Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697 Gesch?ftsf?hrer: Alexander van der Ven, Jan Schultheiss, Val Maher Oracle is committed to developing practices and products that help protect the environment