6 Replies Latest reply on Nov 19, 2010 9:38 PM by 679941

    NPE after null check

      During stress testing, after several hours (15), several NullPointerException start to occur.
      Which, according to the line number is confusing.

      if ( expectedType != null )
      if ( !(expectedType.isInstance(value) ) ) <<<NPE occurring here

      The .class file also shows that the line in question would be here:
      /* 141*/ if(expectedType != null && !expectedType.isInstance(value))

      Is this happening b/c of some hotspot null check eliminator?
        • 1. Re: NPE after null check
          Is expectedType a member variable (as opposed to a local)?

          And is this a multithreaded app?

          Alternatively, are you 100% sure that the version of the source you're looking at is the same as the version that's running, so that that's the right line number?

          Are you 100% sure that the real culprit isn't another line, inside the isInstance() method?

          Barring a rather serious bug in the JVM, there's no way that the line in question could cause NPE unless expectedType gets changed by another thread between the if check and the method call.

          Edited by: jverd on Nov 16, 2010 4:44 PM
          • 2. Re: NPE after null check
            Right, sorry...

            key is a method param:

            public MyContext setParameter( MyKey key, Serializable value )

            Class<?> expectedType= key.getExpectedType();
            if ( expectedType != null )
            if ( !(expectedType.isInstance(value) ) )

            Another thing that's odd is that from the stack trace, that particular key is an interface var (public static final)...and the expected type is initially set...and I don't know of anything that updates it.
            • 3. Re: NPE after null check
              What VM are you using?

              Are you using JNI in your code or third party?
              • 4. Re: NPE after null check
                No JNI that I know of....

                <BEA-141187> <Java system properties are defined as follows:
                USE_JAAS = false
                java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
                java.awt.headless = true
                java.awt.printerjob = sun.print.PSPrinterJob
                java.class.version = 50.0
                java.home = /scratch/x/jrockit-jdk1.6.0_20/jre
                java.io.tmpdir = /tmp
                java.library.path = /scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/amd64/jrockit:/scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/amd64:/scratch/xxx/jrockit-jdk1.6.0_20/jre/../lib/amd64:/scratch/xxx/MWhome/wlserver_10.3/server/native/linux/i686:/scratch/xxx/MWhome/patch_wls1034/profiles/default/native:/scratch/xxx/MWhome/patch_ocp360/profiles/default/native:/scratch/xxx/MWhome/wlserver_10.3/server/native/linux/x86_64:/scratch/xxx/MWhome/wlserver_10.3/server/native/linux/x86_64/oci920_8
                java.naming.factory.initial = weblogic.jndi.WLInitialContextFactory
                java.naming.factory.url.pkgs = weblogic.jndi.factories:weblogic.corba.j2ee.naming.url:weblogic.jndi.factories:weblogic.corba.j2ee.naming.url
                java.protocol.handler.pkgs = oracle.mds.net.protocol|weblogic.net
                java.runtime.name = Java(TM) SE Runtime Environment
                java.runtime.version = 1.6.0_20-b02
                java.security.policy = /scratch/xxx/MWhome/wlserver_10.3/server/lib/weblogic.policy
                java.specification.name = Java Platform API Specification
                java.specification.vendor = Sun Microsystems Inc.
                java.specification.version = 1.6
                java.vendor = Oracle Corporation
                java.vendor.url = http://www.oracle.com/
                java.vendor.url.bug = http://download.oracle.com/docs/cd/E15289_01/go2troubleshooting.html
                java.version = 1.6.0_20
                java.vm.info = compiled mode
                java.vm.name = Oracle JRockit(R)
                java.vm.specification.name = Java Virtual Machine Specification
                java.vm.specification.vendor = Sun Microsystems Inc.
                java.vm.specification.version = 1.0
                java.vm.vendor = Oracle Corporation
                java.vm.vendor.url = http://www.oracle.com/
                java.vm.vendor.url.bug = http://download.oracle.com/docs/cd/E15289_01/go2troubleshooting.html
                java.vm.version = R28.1.0-120-137830-1.6.0_20-20100922-1826-linux-x86_64
                javax.management.builder.initial = weblogic.management.jmx.mbeanserver.WLSMBeanServerBuilder
                javax.rmi.CORBA.PortableRemoteObjectClass = weblogic.iiop.PortableRemoteObjectDelegateImpl
                javax.rmi.CORBA.UtilClass = weblogic.iiop.UtilDelegateImpl
                javax.xml.rpc.ServiceFactory = weblogic.webservice.core.rpc.ServiceFactoryImpl
                javax.xml.soap.MessageFactory = weblogic.webservice.core.soap.MessageFactoryImpl
                jrockit.codegen.newlockmatching = true
                jrockit.optfile = /scratch/xxx/MWhome/oracle_common/modules/oracle.jrf_11.1.1/jrocket_optfile.txt
                kernel.download.enabled = false
                sun.boot.class.path = /scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/resources.jar:/scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/rt.jar:/scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/sunrsasign.jar:/scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/jsse.jar:/scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/jce.jar:/scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/charsets.jar:/scratch/xxx/jrockit-jdk1.6.0_20/jre/classes
                sun.boot.library.path = /scratch/xxx/jrockit-jdk1.6.0_20/jre/lib/amd64
                sun.cpu.endian = little
                sun.io.unicode.encoding = UnicodeLittle
                sun.java.launcher = SUN_STANDARD
                sun.jnu.encoding = UTF-8
                sun.management.compiler = Oracle JRockit(R) Optimizing Compiler
                sun.os.patch.level = unknown
                • 5. Re: NPE after null check
                  Which, according to the line number is confusing.
                  As another suggestion, what is running might not match your source code, thus leading to another line.
                  That is a commercial product of which there isn't as much expertise here. However you should also have a support avenue for that so you can ask about errors from that avenue.
                  • 6. Re: NPE after null check
                    Yes, that was my fault for posting to the wrong group...I posted to an jrockit mail list and got tips on disabling optimization for a specific class.