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

HadoopMarc <bi...@...>

Hi Toom,

You are right, my bad. I can confirm this behaviour. Can you also document how this affects the use of  JanusGraphManagement.setConsistency?

void setConsistency(JanusGraphSchemaElement element, ConsistencyModifier consistency);

Note that this method takes a ConsistencyModifier, not a ModifierType, that is why I ask.

Best wishes,    Marc

Op dinsdag 1 september 2020 om 08:09:12 UTC+2 schreef toom:

Cyclical dependency is not the right term. Static part of both class refers static member of the other.
Anyway, I use your pom.xml and I reproduce the problem with Oracle java 8 (maybe it depends on the order of class load):
$ cat src/main/java/ 

public class JGModifierTypeIssue {
    public static void main(String[] args) {
$ mvn exec:java -Dexec.mainClass="JGModifierTypeIssue"
[INFO] Scanning for projects...
[INFO] -----------------------< org.example:jgquestion >-----------------------
[INFO] Building jgquestion 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ jgquestion ---
    at<clinit> (
    at JGModifierTypeIssue.main (
    at org.codehaus.mojo.exec.ExecJavaMojo$ (
    at (
Caused by: java.lang.NullPointerException
    at (
    at org.janusgraph.graphdb.types.TypeDefinitionCategory.<clinit> (
    at<clinit> (
    at JGModifierTypeIssue.main (
    at org.codehaus.mojo.exec.ExecJavaMojo$ (
    at (
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.682 s
[INFO] Finished at: 2020-09-01T08:05:43+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project jgquestion: An exception occured while executing the Java class. null: ExceptionInInitializerError: NullPointerException -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)



On Monday, August 31, 2020 at 9:31:30 PM UTC+2 HadoopMarc wrote:
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=""




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

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.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

Should I create an issue on Github ?



Join { to automatically receive all group messages.