Skip to content

ClassJS v0.1-alpha.4

Pre-release
Pre-release

Choose a tag to compare

@Pelemenguin Pelemenguin released this 17 Oct 12:25
· 10 commits to 1.20.1 since this release

New Features

  • ClassJSUtils.loadClass

    • Allows to load a class that was created by ClassCreator.
    let TestClass = ClassCreator.create("TestClass")
        .toPublic()
        .defaultConstructor()
        .defineClass();
    
    let loaded = ClassJSUtils.loadClass("TestClass");
    console.info(loaded === TestClass); // true
  • MethodCreator.codeJSWithThis

    • Allows to define a method where the first parameter is this.
    let TestClass = ClassCreator.create("TestClass")
        .toPublic()
        .defaultConstructor()
        .createField("testField", "int")
            .toPublic()
            .build()
        .createMethod("testMethod", ["java.lang.String", "int"], "void")
            .toPublic()
            .codeJSWithThis((thisObj, s, r) => {
                // Now, `thisObj` represents the instance of TestClass
                console.info(s + 's'.repeat(r));
                thisObj.testField = r;
            })
        .defineClass();

Fixed Bugs

  • Reloading methods written in invokeJS that are never used caused NullPointerException.
  • Specifying a method's parameter types or its return type as the currently defining class caused TypeNotPresentException.