Reputation: 2012
After upgrading from Java 6 to Java 8, my application throws the following exception:
com.mathworks.toolbox.javabuilder.MWException: Java exception occurred:
java.lang.NullPointerException
at java.util.logging.Logger.demandLogger(Logger.java:451)
at java.util.logging.Logger.getLogger(Logger.java:502)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclFeval(Native Method)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.access$600(MWMCR.java:23)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$6.mclFeval(MWMCR.java:833)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.mathworks.toolbox.javabuilder.internal.MWMCR$5.invoke(MWMCR.java:731)
at com.sun.proxy.$Proxy2.mclFeval(Unknown Source)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.invoke(MWMCR.java:406)
at mDataEngine.mDataEngineMIF.volatility(mDataEngineMIF.java:7212)
This occurs when using the mathworks library, which in turn uses java.util.logging.Logger where the exception is thrown.
Upvotes: 2
Views: 3364
Reputation: 11045
The Oracle bug JDK-8145302 NullPointerException at java.util.logging.Logger.demandLogger has been replaced with
The workaround in that bug report is listed as:
Workaround: use an auxiliary class in order to call Logger.getLogger instead of calling Logger::getLogger directly from JNI.
As you can see from your stacktrace:
java.lang.NullPointerException
at java.util.logging.Logger.demandLogger(Logger.java:451)
at java.util.logging.Logger.getLogger(Logger.java:502)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.mclFeval(Native Method)
...
the com.mathworks.toolbox.javabuilder.internal.MWMCR.mclFeval
is a JNI method calling java.util.logging.Logger.getLogger
.
Mathworks should update the MWMCR
class to include a java helper method to invoke getLogger
and that helper method should be called from JNI instead of getLogger
directly.
Upvotes: 1
Reputation: 2012
This can be solved by setting the following system property when starting the Java program:
-Dsun.util.logging.disableCallerCheck=true
More detailed information:
The reason for the NullpointerException seems to be explained here: http://www.infoq.com/news/2013/07/Oracle-Removes-getCallerClass
The method getCallerClass is used here in java.util.logging.Logger:
public static Logger More ...getLogger(String name) {
return demandLogger(name, null, Reflection.getCallerClass());
}
This leads to the variable caller to be null in the following code of java.util.logging.Logger:
if (sm != null && !SystemLoggerHelper.disableCallerCheck) {
if (caller.getClassLoader() == null) {
return manager.demandSystemLogger(name, resourceBundleName);
}
}
return manager.demandLogger(name, resourceBundleName, caller);
By setting the systemvariable as explained above, the caller variable will not be used.
Upvotes: 2