Skip to main content

module lang::flybytes::Mirror

rascal-0.34.0
flybytes-0.2.3

Provides a native interface to Java objects via class and object reflection.

Usage

import lang::flybytes::Mirror;

Source code

http://github.com/usethesource/flybytes/blob/main/src/lang/flybytes/Mirror.rsc

Dependencies

import lang::flybytes::Syntax;

Description

Using this Mirror representation you can test generated class files by loading the class and executing static methods on the classes, getting static fields, allocating new instances, calling methods on these instances, etc. There is also support for native arrays.

data Mirror

data Mirror  
= class(str class,
Mirror (Signature method, list[Mirror] args) invokeStatic,
Mirror (str name) getStatic,
Mirror (Signature constructor, list[Mirror] args) newInstance,
Mirror (Type \type) getAnnotation)
| object(Mirror classMirror,
Mirror (Signature method, list[Mirror] args) invoke,
Mirror (str name) getField,
&T (type[&T] expect) toValue)
| array(int () length,
Mirror (int index) load)
| \null()
;

function val

reflects a Rascal value as a JVM object Mirror

Mirror val(value v)

function classMirror

reflects a JVM class object as Mirror class

Mirror classMirror(str name,list[loc] classpath = [|system:///|])

function array

creates a mirrored array

Mirror array(Type \type, list[Mirror] elems)

function array

creates a mirrored array

Mirror array(Type \type, int length)

function toString

str toString(Mirror m:object(_, _, _, _))

str toString(class(str name, _, _, _, _))

str toString(null())

str toString(Mirror m:array(_, _))

function integer

Mirror integer(int v)

function long

Mirror long(int v)

function byte

Mirror byte(int v)

function short

Mirror short(int v)

function character

Mirror character(int v)

function string

Mirror string(str v)

function double

Mirror double(real v)

function float

Mirror float(real v)

function boolean

Mirror boolean(bool v)

function prim

Mirror prim(integer(), int t)

Mirror prim(short(), int t)

Mirror prim(byte(), int t)

Mirror prim(long(), int t)

Mirror prim(double(), real t)

Mirror prim(float(), real t)

Mirror prim(string(), str t)

Mirror prim(character(), int t)

Mirror prim(boolean(), bool t)

function integer

int integer(Mirror i)

function long

int long(Mirror l)

function byte

int byte(Mirror b)

function short

int short(Mirror s)

function string

str string(Mirror s)

function double

real double(Mirror d)

function float

real float(Mirror f)

function character

int character(Mirror f)

function boolean

bool boolean(Mirror f)