Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-505

NPE in the OWL class

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Done
    • Jena 2.10.1
    • Jena 2.11.0
    • Jena
    • None

    Description

      The error happens when you try to load a file using the file manager in Jena 2.10.1, for example

      model = FileManager.get().loadModel("http://example.org","http://example.org","RDF/XML");
      

      The reason is incorrect initialization of variables in the OWL class. In the following code:

          public class OWL {
              private static Model m_model = ModelFactory.createDefaultModel();
              
              public static final String NS = "http://www.w3.org/2002/07/owl#";
              
              public static String getURI() {return NS;}
          
          ...    
              public static final Property sameAs = m_model.createProperty( "http://www.w3.org/2002/07/owl#sameAs" );
          ...
      

      a call to OWL.sameAs will result in a NPE because m_model is null. I guess that if you start with OWL.getURI(), then m_model will be evaluated first and there will be no error, which is why this never occurred before.

      I think that a solution would be to make m_model final as well.

      Attachments

        1. jena-505.zip
          8 kB
          Piotr Hołubowicz

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            andy Andy Seaborne
            piotrekhol Piotr Hołubowicz
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment