I have currently got working, the ability to inline java into B4J not like #If JAVA ...#End If, but inside a sub if needed. It's still rough at present, but a few sneak views of what it looks like.
(in the above read @@ as ")
Just a fun project as it allows java access to local variables inside subs.
Currently working on release , but doesnt break debug, just ignores the java inserts.
B4J code:
Sub listSort(mylist As List)
java("_mylist.getObject().sort((a, b) -> ((Comparable)a).compareTo(b))")
java("System.out.println(@@Class: @@ + _mylist.getClass())")
java("for (Field f : _mylist.getClass().getDeclaredFields()) System.out.println(@@Declared: @@ + f)")
java("for (Field f : _mylist.getClass().getFields()) System.out.println(@@Public: @@ + f)")
java("for (Field f : _mylist.getClass().getSuperclass().getDeclaredFields()) System.out.println(@@Super: @@ + f)")
End Sub
The generated Java:
public String _listsort(anywheresoftware.b4a.objects.collections.List _mylist) throws Exception{
//BA.debugLineNum = 13;BA.debugLine="Sub listSort(mylist As List)";
//BA.debugLineNum = 14;BA.debugLine="java(\"_mylist.getObject().sort((a, b) -> ((Compar";
_mylist.getObject().sort((a, b) -> ((Comparable)a).compareTo(b));
//BA.debugLineNum = 15;BA.debugLine="java(\"System.out.println("Class: " + _mylist.ge";
System.out.println("Class: " + _mylist.getClass());
//BA.debugLineNum = 16;BA.debugLine="java(\"for (Field f : _mylist.getClass().getDeclar";
for (Field f : _mylist.getClass().getDeclaredFields()) System.out.println("Declared: " + f);
//BA.debugLineNum = 17;BA.debugLine="java(\"for (Field f : _mylist.getClass().getFields";
for (Field f : _mylist.getClass().getFields()) System.out.println("Public: " + f);
//BA.debugLineNum = 18;BA.debugLine="java(\"for (Field f : _mylist.getClass().getSuperc";
for (Field f : _mylist.getClass().getSuperclass().getDeclaredFields()) System.out.println("Super: " + f);
//BA.debugLineNum = 19;BA.debugLine="End Sub";
return "";
}
Just a fun project as it allows java access to local variables inside subs.
Currently working on release , but doesnt break debug, just ignores the java inserts.