FULL PRODUCT VERSION :
java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Hi, it seems that lots of time is being wasted in xerces in reflection. I have nailed it down to this method:
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory.getInstance();
I think the problem is it spending a lot of time using reflection to get the class.
Is this reflection necessary? If it is could you please add comments justifying why reflection should be used on each call, and why caching the class is not possible.
Otherwise, could we cache the class for example:
//On the first call we get the class
Class cachedClass = com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass("com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl", true);
//On all future calls we use the cachedClass
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory factory =
(com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory) cachedClass.newInstance();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The speed of those tests should be the same.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
here are two tests when normal() is slower than optimise than the problem is still occurring (sorry it is still rather manual)
@Test
public void normal() {
for(int i = 0; i < 100000; i++) {
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory.getInstance();
}
}
@Test
public void optimise() throws Exception {
//findProviderClass
Class cachedClass = com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass("com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl", true);
for(int i = 0; i < 100000; i++) {
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory factory =
(com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory) cachedClass.newInstance();
}
}
---------- END SOURCE ----------
java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Hi, it seems that lots of time is being wasted in xerces in reflection. I have nailed it down to this method:
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory.getInstance();
I think the problem is it spending a lot of time using reflection to get the class.
Is this reflection necessary? If it is could you please add comments justifying why reflection should be used on each call, and why caching the class is not possible.
Otherwise, could we cache the class for example:
//On the first call we get the class
Class cachedClass = com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass("com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl", true);
//On all future calls we use the cachedClass
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory factory =
(com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory) cachedClass.newInstance();
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The speed of those tests should be the same.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
here are two tests when normal() is slower than optimise than the problem is still occurring (sorry it is still rather manual)
@Test
public void normal() {
for(int i = 0; i < 100000; i++) {
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory.getInstance();
}
}
@Test
public void optimise() throws Exception {
//findProviderClass
Class cachedClass = com.sun.org.apache.xerces.internal.utils.ObjectFactory.findProviderClass("com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl", true);
for(int i = 0; i < 100000; i++) {
com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory factory =
(com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory) cachedClass.newInstance();
}
}
---------- END SOURCE ----------