jaxb
  1. jaxb
  2. JAXB-615

JAXBContext.newInstance fails with NPE if class has an Enum

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1.8
    • Fix Version/s: not determined
    • Component/s: runtime
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      615

      Description

      if a class to be bound has a Enum then jaxb seems to assume that it is an enum
      (ie a specific type) and fails to bind. The exception produced is not helpful
      to diagnose the problem. ALso occurs when using generics and the erased type is
      Enum (this is how I found it)

      This was checked against 2.1.10 and 2.1.8 (2.1.10 in not in the bug version
      list)

      stack trace from 2.1.10 for the test code is

      Exception in thread "main" java.lang.NullPointerException
      at java.util.EnumMap.<init>(EnumMap.java:110)
      at com.sun.xml.bind.v2.model.impl.RuntimeEnumLeafInfoImpl.<init>
      (RuntimeEnumLeafInfoImpl.java:83)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createEnumLeafInfo
      (RuntimeModelBuilder.java:105)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createEnumLeafInfo
      (RuntimeModelBuilder.java:81)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
      (ModelBuilder.java:224)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:100)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:81)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
      (ModelBuilder.java:209)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:95)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:81)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
      (ModelBuilder.java:315)
      at com.sun.xml.bind.v2.model.impl.TypeRefImpl.calcRef
      (TypeRefImpl.java:92)
      at com.sun.xml.bind.v2.model.impl.TypeRefImpl.getTarget
      (TypeRefImpl.java:69)
      at com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget
      (RuntimeTypeRefImpl.java:58)
      at com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget
      (RuntimeTypeRefImpl.java:51)
      at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get
      (ElementPropertyInfoImpl.java:74)
      at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get
      (ElementPropertyInfoImpl.java:77)
      at java.util.AbstractList$Itr.next(AbstractList.java:422)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
      (ModelBuilder.java:255)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:100)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:81)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo
      (ModelBuilder.java:209)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:95)
      at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo
      (RuntimeModelBuilder.java:81)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
      (ModelBuilder.java:315)
      at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo
      (ModelBuilder.java:330)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet
      (JAXBContextImpl.java:441)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>
      (JAXBContextImpl.java:288)
      at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build
      (JAXBContextImpl.java:1111)
      at com.sun.xml.bind.v2.ContextFactory.createContext
      (ContextFactory.java:154)
      at com.sun.xml.bind.v2.ContextFactory.createContext
      (ContextFactory.java:121)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke
      (NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke
      (DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
      at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
      at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
      at jaxb.Issue.main(Issue.java:22)

        Activity

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            skells
          • Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: