Skip to content

Annotation

The annotations are used to control the behavior of jCloak to simplify which classes are being protected, and which class is the entrypoint. Both roles will be explained in detail below.

JCloakEntrypoint

The JCloakEntrypoint is the most important annotation. Without it’s existance, jCloak won’t work. As its name suggests, it should be used on the class that is being loaded first. This is typically the Main class.

@JCloakEntrypoint
public class Main {
public static void main(String[] args) {
new TestClass();
}
}

JCloakLoaded

The JCloakLoaded annotation marks the class for processing and thus - with one exception - hides it from the jar.

@JCloakLoaded
public class TestClass {
public TestClass() {
System.out.println("Hello World");
}
}

Native Implementation

You can also create a native dummy class which has native methods to fake a native implementation. This is especially usefull when you want to expose api endpoints while hiding their implementation.

This can be done by setting the value of the annotation to NATIVE_DUMMY:

@JCloakLoaded(NATIVE_DUMMY)
public class TestClass {
public TestClass() {
System.out.println("Hello World");
}
}

The resulting jar will include a class that looks as follows:

public class TestClass {
public native TestClass();
}

This might throw reverse engineers into wrong directions when trying to break you application. It poses no further protection than this.