Re: Use of ModifierType fails if TypeDefinitionCategory is not loaded before


HadoopMarc <bi...@...>
 

Hi Thomas,

Thanks for asking on the user group first. I cannot reproduce the issue (works fine on my system using java8).

I ran:
    mvn exec:java -Dexec.mainClass="JGModifierTypeIssue"

and get CONSISTENCY printed whether the TypeDefinitionCategory line is commented out or not.
I used the pom.xml file below.
Also, java does not have the concept of cyclical dependencies (as in python): an import causes a class load unless the class is already loaded.

HTH,    Marc

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>jgquestion</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-core</artifactId>
<version>0.5.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>maven</executable>
</configuration>
</plugin>
</plugins>
</build>
</project>

Op maandag 31 augustus 2020 om 15:30:57 UTC+2 schreef Thomas Franco:

Hi,

When I try to set consistency of a property key (using JanusGraphManagement.setConsistency in a java project) I get a NPE if I don't refer the class TypeDefinitionCategory before.

The method setConsistency uses ModifierType and there is a cyclic dependency between  ModifierType  and TypeDefinitionCategory.

You can reproduce the error with this minimalist java code:
import org.janusgraph.graphdb.database.management.ModifierType;
import org.janusgraph.graphdb.types.TypeDefinitionCategory;

public class JGModifierTypeIssue {
  public static void main(String[] args) {
    TypeDefinitionCategory dummy = TypeDefinitionCategory.BACKING_INDEX
    // without the following line the next line generates a NPE
    System.out.println(ModifierType.CONSISTENCY);
  }
}

Should I create an issue on Github ?

Regards,

Toom.


Join {janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.