Hi JAXB Team,
I'm using jwsdp 1.6 which contains jaxb (Specification Version: 1.0
Reference Implementation (RI) Version: 1.0.5)
and I think I found a bug in the generated runtime code.
When using "DefaultJAXBContextImpl.newInstance(java.lang.Class
javaContentInterface)" only the first grammarInfo is searched for the
given content interface,
because GrammarInfoImpl.getDefaultImplementation( Class
javaContentInterface ) calls Class.forName(null, true, classLoader) and
hence throws a NullPointerException.
This could be fixed by changing a)
GrammarInfoImpl.getDefaultImplementation or b)
GrammarInfoFacade.getDefaultImplementation.
a) Change the following in the generated Code of GrammarInfoImpl from
##########################################################
public final Class getDefaultImplementation( Class
javaContentInterface ) {
try {
// by caching the obtained Class objects.
return
Class.forName((String)defaultImplementationMap.get(javaContentInterface),
true, classLoader );
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError(e.toString());
}
}
##########################################################
to
##########################################################
public final Class getDefaultImplementation( Class
javaContentInterface ) {
try {
// by caching the obtained Class objects.
String className =
(String)defaultImplementationMap.get(javaContentInterface);
if (className != null)
return Class.forName(className, true, classLoader );
else
return null;
} catch (ClassNotFoundException e) {
throw new NoClassDefFoundError(e.toString());
}
}
##########################################################
b) Change the following in the generated Code of GrammarInfoFacade from
##########################################################
public Class getDefaultImplementation( Class javaContentInterface ) {
for( int i=0; i<grammarInfos.length; i++ ) {
Class c = grammarInfos[i].getDefaultImplementation(
javaContentInterface );
if(c!=null) return c;
}
return null;
}
##########################################################
to
##########################################################
public Class getDefaultImplementation( Class javaContentInterface ) {
for( int i=0; i<grammarInfos.length; i++ ) {
Class c = null;
try {
c = grammarInfos[i].getDefaultImplementation(
javaContentInterface );
} catch (NoClassDefFoundError e) {
//continue
} catch (NullPointerException e) {
//continue
}
if(c!=null) return c;
}
return null;
}
##########################################################
best regards
Konrad Lanz
Konrad(dot)Lanz[AT]iaik{dot}tugraz<dot>at