Fan

 

class

compilerJava::JavaBridge

sys::Obj
  compiler::CompilerSupport
    compiler::CBridge
      compilerJava::JavaBridge

@compilerBridge = "java"

JavaBridge is the compiler plugin for bringing Java classes into the Fan type system.

Slots

areParamsSameSource

static Bool areParamsSame(CMethod a, CMethod b)

Do the two methods have the exact same parameter types.

checkOverrideSource

override Void checkOverride(TypeDef t, CSlot base, SlotDef def)

Called during Inherit step when a Fan slot overrides a FFI slot. Log and throw compiler error if there is a problem.

checkTypeSource

override Void checkType(TypeDef def)

Called during CheckErrors step for a type which extends a FFI class or implements any FFI mixins.

classTypeSource

JavaType classType()

Get a CType representation for java.lang.Class

coerceSource

override Expr coerce(Expr expr, CType expected, |,| onErr)

Coerce expression to expected type. If not a type match then run the onErr function.

coerceFromArraySource

Expr coerceFromArray(Expr expr, CType expected, |,| onErr)

Coerce a Java array to a Fan list.

coerceFromPrimitiveSource

Expr coerceFromPrimitive(Expr expr, CType expected, |,| onErr)

Coerce a Java primitive to a Fan type.

coerceFuncToInterfaceSource

Expr coerceFuncToInterface(Expr expr, JavaType expected, |,| onErr)

Attempt to coerce a parameterized sys::Func expr to a Java interface if the interface supports exactly one matching method.

coerceToArraySource

Expr coerceToArray(Expr expr, CType expected, |,| onErr)

Coerce a Fan list to Java array.

coerceToPrimitiveSource

Expr coerceToPrimitive(Expr expr, JavaType expected, |,| onErr)

Coerce a fan expression to a Java primitive (other than the ones we support natively)

cpSource

readonly ClassPath cp

fitsSource

Bool fits(CType actual, CType expected)

Return if we can make the actual type fit the expected type, potentially using a coercion.

generateFuncToInterfaceWrapperSource

CMethod generateFuncToInterfaceWrapper(Location loc, FuncType funcType, CType expected, CMethod method)

Generate the wrapper which implements the specified expected interface and overrides the specified method which calls the function.

isFuncToInterfaceMatchSource

Bool isFuncToInterfaceMatch(FuncType funcType, CMethod method)

Return if the specified function type can be used to implement the specified interface method.

listAsArraySource

CMethod listAsArray()

Get a CMethod representation for Object[] List.asArray()

listMakeFromArraySource

CMethod listMakeFromArray()

Get a CMethod representation for List.make(Type, Object[])

makeSource

new make(Compiler c)

Construct a JavaBridge for current environment

objectArrayTypeSource

JavaType objectArrayType()

Get a CType representation for java.lang.Object[]

primitivesSource

readonly JavaPrimitives primitives := JavaPrimitives(this)

resolveCallSource

override CallExpr resolveCall(CallExpr call)

Resolve a method call: try to find the best match and apply any coercions needed.

resolveConstructionSource

override Expr resolveConstruction(CallExpr call)

Resolve a construction call to a Java constructor.

resolveConstructorChainSource

override Expr resolveConstructorChain(CallExpr call)

Resolve a construction chain call where a Fan constructor calls the super-class constructor. Type check the arguments and insert any conversions needed.

resolvePodSource

override CPod resolvePod(Str name, Location? loc)

Map a FFI "podName" to a Java package.