PBJ::JNI::Native - Perl interface to Java JNI


PBJ-JNI documentation  | view source Contained in the PBJ-JNI distribution.

Index


NAME

Top

PBJ::JNI::Native - Perl interface to Java JNI

SYNOPSIS

Top

    # use through the PBJ::JNI::JavaVM module, not directly.
    use PBJ::JNI::JavaVM;

    my ($env, $jvm, @vm_opts);
    my ($cls, $fid, $mid, $out);

    # Create the Java VM
    @vm_opts = ("-Xrs", "-Xcheck:jni");
    $jvm = new PBJ::JNI::JavaVM();
    $env = $jvm->get_env(@vm_opts);

    $env->PushLocalFrame(16) == 0 or die;
    $cls = $env->FindClass("java/lang/System") or die;
    $fid = $env->GetStaticFieldID($cls, "out", "Ljava/io/PrintStream;") or die;
    $out = $env->GetStaticObjectField($cls, $fid) or die;
    $cls = $env->GetObjectClass($out) or die;
    $mid = $env->GetMethodID($cls, "println", "(I)V") or die;
    $env->CallVoidMethod($out, $mid, $env->cast("I", 12345));
    $env->PopLocalFrame(0);




DESCRIPTION

Top

This is the native interface to JNI library. All function names are closely resembling the ones in the Java JNI library, with some necessary exceptions. This module should not be used directly. All subroutines are called via the PBJ::JNI::JNIEnv module.

EXPORT

None.

AUTHOR

Top

Ping Liang, <ping@cpan.org>

SEE ALSO

Top

perl.

COPYRIGHT and LICENSE

Top


PBJ-JNI documentation  | view source Contained in the PBJ-JNI distribution.