jasonjack2015 / protobuf

Automatically exported from code.google.com/p/protobuf
Other
0 stars 0 forks source link

Use of Class.forName without specifying the ClassLoader is not OSGi friendly #659

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This statement 
http://code.google.com/p/protobuf/source/browse/trunk/java/src/main/java/com/goo
gle/protobuf/GeneratedMessageLite.java#920 can cause a ClassNotFoundException 
when deserializing a protobuf message in an OSGi environment.

More in general, using Class.forName without specifying the ClassLoader is not 
OSGi friendly. Replacing that statement with the following one is enough to fix 
this problem.

Class messageClass = Class.forName(messageClassName, true, 
Thread.currentThread().getContextClassLoader());

Nevertheless it would be even better if it was possible to pass to protobuf a 
specific ClassLoader when performing a deserialization.

Original issue reported on code.google.com by mario.fu...@gmail.com on 5 Aug 2014 at 5:09