Using Java from Junicon

A key feature of Junicon is its seamless integration with Java, which allows Unicon values and class fields to be passed to and from Java methods, and vice-versa. Junicon maps, lists, and sets are just their equivalent Java types, so any Java methods can be used on them. When run interactively, Java methods can be used transparently. When compiling to Java, however, casts may be needed, and Java method invocation must be indicated using "::" to distinguish it from the lambda expression invocation used by Junicon methods. Java code can also be injected into Junicon using @<script> scoped annotations.

An example follows that shows how to use Java methods, as well as how to inject Java code directly into a Unicon program.

class E {
  local x,y;
  method foo() {
	x := [1,2,3];
	((List) x)::add(4);
	System.out::println(x);
	@<script lang="java">
		y="hello"; System.out.println(y); 
	@</script>
  }
};
z := E();
z.foo();