Android Question Doesn't SLC tool support void method and no parameter method?

teddybear

Well-Known Member
Licensed User
I'm learning slc tool, according to SLC FirstLib example it works well. I want to add a member and 2 methods-set ,get. SLC compiled is successfully, but the xml seems to have some problems. B4A refreshing library reports Error parsing libraries - Object reference not set to an instance of an object.

SLC version is 1.11, JDK11

FirstLib.java
Java:
package b4x.example;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;

@Version(1.0f)
//@Permissions(values={"android.permission.INTERNET"})
@ShortName("FirstLib")
//@DependsOn(values={"some java library "})
//@ActivityObject
public class FirstLib {
    private String a;
    public int add(int x, int y) { // ok
        return x + y;
    }
  
    public int sub(int x, int y) { // ok
            return x - y;
    }
    public void set(String x) { // Genrated xml is incorrect 
        this.a = x;
    }
    public String get() { //  Genrated xml is incorrect

        return this.a;
    }

}

Compiler logs
B4X:
Starting step: Compiling Java code.
javac 11-ea
[0x7FF9276D6700] ANOMALY: meaningless REX prefix used

Completed successfully.
Starting step: Creating jar file.
Completed successfully.
Starting step: Creating XML file.
���ڼ���Դ�ļ�D:\B4X\SimpleLibraryCompiler\FirstLibrary\src\b4x\example\FirstLib.java...
���ڹ��� Javadoc ��Ϣ...
[-doclet, BADoclet]
[-docletpath, D:\B4X\SimpleLibraryCompiler]
[-doclet, BADoclet]
[-docletpath, D:\B4X\SimpleLibraryCompiler]
[-bootclasspath, D:\software\B4A\android\platforms\android-30\android.jar]
[-classpath, d:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\B4AShared.jar;d:\Program Files (x86)\Anywhere Software\Basic4android\B4A.exe\../libraries\Core.jar;D:\B4X\SimpleLibraryCompiler\FirstLibrary\libs\android.jar;D:\B4X\SimpleLibraryCompiler\FirstLibrary\libs\B4AShared.jar;D:\B4X\SimpleLibraryCompiler\FirstLibrary\libs\Core.jar;]
[-sourcepath, src]
[-b4atarget, D:\B4X\B4A\AdditionlLibraries\FirstLib.xml]
[-b4aignore, org,com.android,com.example,com.hoho]
Ignoring: [org, com.android, com.example, com.hoho]
starting....
Working with class: b4x.example.FirstLib
finish: D:\B4X\B4A\AdditionlLibraries\FirstLib.xml
[0x7FF9276D6700] ANOMALY: meaningless REX prefix used

Completed successfully.
*** Don't forget to refresh the libraries list in the IDE (right click and choose Refresh) ***

FirstLib.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
    <doclet-version-NOT-library-version>1.07</doclet-version-NOT-library-version>
    <class>
        <name>b4x.example.FirstLib</name>
        <shortname>FirstLib</shortname>
        <owner>process</owner>
        <method>
            <name>add</name>
            <comment></comment>
            <returntype>int</returntype>
            <parameter>
                <name>x</name>
                <type>int</type>
            </parameter>
            <parameter>
                <name>y</name>
                <type>int</type>
            </parameter>
        </method>
        <method>
            <name>sub</name>
            <comment></comment>
            <returntype>int</returntype>
            <parameter>
                <name>x</name>
                <type>int</type>
            </parameter>
            <parameter>
                <name>y</name>
                <type>int</type>
            </parameter>
        </method>
        <property>
            <name></name>
            <returntype>java.lang.String</returntype>
            <parameter>
                <name>x</name>
                <type>java.lang.String</type>
            </parameter>
            <comment></comment>
        </property>
    </class>
    <version>1.0</version>
</root>

They seem not to generate method in the xml, just a property.If I give method a type and parameters, the xml file will be ok.

 
Last edited:

agraham

Expert
Licensed User
Longtime User
Use Java 8 with SLC.
From my notes 😁
Erel said on the forum 25th August 2020 after another user also encountered problems with Java 11 and BADoclet
"It will be fixed at some point."
Eighteen months and counting! :)
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Use Java 8 with SLC.
I have uninstalled jdk 11 and installed java 8 ,the problem remains.

Which java 8 version is required?
The following is my b4a javac
B4X:
B4A Version: 11.20
Parsing code.    (0.00s)
    Java Version: 8
Building folders structure.    (0.11s)
Compiling code.    (0.04s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
    (AndroidX SDK)
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
public void set(String x) { // Genrated xml is incorrect
This is the problem. In a library properties are distinguished from methods by a property having lowercase 'set' or 'get' prefix. This line is confusing BADoclet. Rename it to something more sensible.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
This is the problem. In a library properties are distinguished from methods by a property having lowercase 'set' or 'get' prefix. This line is confusing BADoclet. Rename it to something more sensible.
Thanks a lot. it works well. I got it, set and get is key words in BADoclet.
 
Last edited:
Upvote 0
Top