-
Bug
-
Resolution: Done
-
Major
-
0.66.10
-
None
In some circumstances initialisation of Command by reflection fails with:
java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.aesh.util.ReflectionUtil.newInstanceWithParameterTypes(ReflectionUtil.java:85)
at org.jboss.aesh.util.ReflectionUtil.instantiateWithConstructor(ReflectionUtil.java:64)
at org.jboss.aesh.util.ReflectionUtil.newInstance(ReflectionUtil.java:38)
at org.jboss.aesh.cl.parser.ParserGenerator.doGenerateCommandLineParser(ParserGenerator.java:120)
at org.jboss.aesh.cl.parser.ParserGenerator.doGenerateCommandLineParser(ParserGenerator.java:121)
at org.jboss.aesh.cl.parser.ParserGenerator.generateCommandLineParser(ParserGenerator.java:65)
at org.jboss.aesh.console.command.container.AeshCommandContainerBuilder.create(AeshCommandContainerBuilder.java:45)
at org.jboss.aesh.console.command.registry.MutableCommandRegistry.addCommand(MutableCommandRegistry.java:132)
at org.jboss.aesh.console.command.registry.AeshCommandRegistryBuilder.command(AeshCommandRegistryBuilder.java:46)
at org.keycloak.client.registration.cli.KcRegMain.main(KcRegMain.java:38)
Exception in thread "main" java.lang.RuntimeException: java.lang.InstantiationException
at org.jboss.aesh.util.ReflectionUtil.newInstanceWithParameterTypes(ReflectionUtil.java:88)
at org.jboss.aesh.util.ReflectionUtil.instantiateWithConstructor(ReflectionUtil.java:64)
at org.jboss.aesh.util.ReflectionUtil.newInstance(ReflectionUtil.java:38)
at org.jboss.aesh.cl.parser.ParserGenerator.doGenerateCommandLineParser(ParserGenerator.java:120)
at org.jboss.aesh.cl.parser.ParserGenerator.doGenerateCommandLineParser(ParserGenerator.java:121)
at org.jboss.aesh.cl.parser.ParserGenerator.generateCommandLineParser(ParserGenerator.java:65)
at org.jboss.aesh.console.command.container.AeshCommandContainerBuilder.create(AeshCommandContainerBuilder.java:45)
at org.jboss.aesh.console.command.registry.MutableCommandRegistry.addCommand(MutableCommandRegistry.java:132)
at org.jboss.aesh.console.command.registry.AeshCommandRegistryBuilder.command(AeshCommandRegistryBuilder.java:46)
at org.keycloak.client.registration.cli.KcRegMain.main(KcRegMain.java:38)
Caused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.aesh.util.ReflectionUtil.newInstanceWithParameterTypes(ReflectionUtil.java:85)
... 9 more
It seems to have to do with the order in which constructors are returned in ReflectionUtil.java:37.
Instantiation should either always fail, or always succeed. Currently constructors seem to be consistently ordered on most systems / configurations, but unpredictably or differently ordered on some systems / configurations.