You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2019/07/08 10:18:00 UTC

[jira] [Commented] (JENA-1729) A minor initilization issue

    [ https://issues.apache.org/jira/browse/JENA-1729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16880176#comment-16880176 ] 

Andy Seaborne commented on JENA-1729:
-------------------------------------

Thank for the test case.  The same happens for me.

What is your use case for loading graph during Jena system initialization?

Operations such as loading a graph will be suspect - this is a knock on effect of how java class initialization happens. If system initialization is triggered by a call to {{JenaSystem.init}} inside a class initializer, then while that happens, all other class initialization is not being performed (the Java runtime controls this).

Here, it's the constant RDF.type not getting set. It is not happening because java class initialization is started by a  NodeFactory class init block.

The simplest way to initialize is an explicit call of {{JenaSystem.init();}} then perform operations such as reading graphs outside the initialization sequence.

In initialization code, the constant for RDF.type is obtained from {{RDF.Init.type()}} but that assumes the code is "init aware". Reading a graph invokes a lot of code and most if it is not init aware.

The only way I can see to have a better initialization is to have every class that initializes constants to have an "init" call that sets the class statics directly. That has a major downside of an extra requirement of every class. We could do that for one or two key classes.


> A minor initilization issue
> ---------------------------
>
>                 Key: JENA-1729
>                 URL: https://issues.apache.org/jira/browse/JENA-1729
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: Core
>         Environment: java8(1.8.0_152), jena-arq:3.12.0
>            Reporter: ssz
>            Priority: Minor
>             Fix For: Jena 3.12.0
>
>
> The following one-class program fails with assertion error:
>  
> {code:java}
> package xx.yy;
> import org.apache.jena.rdf.model.RDFNode;
> import org.apache.jena.rdf.model.ResourceFactory;
> import org.apache.jena.sys.JenaSubsystemLifecycle;
> import org.apache.jena.sys.JenaSystem;
> import org.apache.jena.vocabulary.RDF;
> public class InitTest implements JenaSubsystemLifecycle {
>     @Override
>     public void start() {
>         if (JenaSystem.DEBUG_INIT)
>             System.err.println("InitTEST -- start");
>         assert RDF.type != null : "RDF#type is null => attempt to load a graph here will fail";
>     }
>     @Override
>     public void stop() {
>         if (JenaSystem.DEBUG_INIT)
>             System.err.println("InitTEST -- finish");
>     }
>     @Override
>     public int level() {
>         return 500;
>     }
>     public static void main(String... args) { // run VM option: -ea
>         JenaSystem.DEBUG_INIT = true;
>         //RDFNode r = ResourceFactory.createProperty("X"); // this works fine
>         RDFNode r = ResourceFactory.createTypedLiteral("Y"); // this causes a problem
>         System.out.println(r);
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)