-
Notifications
You must be signed in to change notification settings - Fork 37
ClassNotFoundException Caused by Missing Separator between Package and Class #524
Description
Description
It is trying to get a fully qualified class name, using the package (PKG) joined by (+) the simple class name (clazz.getSimpleName()) as below.
Line 172 in 544656e
| String classInternalName = PKG + clazz.getSimpleName() + CLASS_LABEL + counter.getAndIncrement(); |
However, there is no separator, i.e. slash (/) between the package and the class.
Furthermore, there is also no trailing slash (/) for the package which is defined as below.
Line 48 in 544656e
| private static final String PKG = "org/springextensions/gef/serialization"; |
Eventually, the result like org/springextensions/gef/serializationCommandResponseInstantiator$Synthetic2, is incorrect.
Note there is supposed to be a slash (/) between serialization and Command actually.
Expected result would be like org/springextensions/gef/serialization/CommandResponseInstantiator$Synthetic2 instead.
Next, it will replace all of the slashes (/) by dots (.) and then try to load the class by the string, which leads to ClassNotFoundException further.
Example error message
The message below was generated by a simple project powered by spring-boot-starter-web, spring-data-geode and geode-core which does nothing other than just starting up.
InstantiatorRecoveryTask - Error ClassNotFoundException: org.springextensions.gef.serializationCommandResponseInstantiator$Synthetic2
Test case
Currently the test case is just simply checking for the symbol of inner class ($) as below, with no further validation.
Lines 72 to 76 in 544656e
| @Test | |
| public void testGeneratedClassName() throws Exception { | |
| Instantiator instantiator = asmFactory.getInstantiator(SomeClass.class, 100); | |
| assertTrue(instantiator.getClass().getName().contains("$")); | |
| } |