Esempio n. 1
0
 /**
  *  Convert a JavaException (from the bridge) into a human-readable PHP Exception.
  *
  *  Basically this just copies the stack trace of the java exception into the Exception's message and throws a normal Exception.
  *
  *  @param object JavaException The exception from the bridge.
  *  @throws object Exception The PHP Exception with the java stack trace.
  */
 private function handleJavaException(JavaException $e)
 {
     $trace = new java("java.io.ByteArrayOutputStream");
     $e->printStackTrace(new java("java.io.PrintStream", $trace));
     throw new Exception("java exception {$e->getMessage()}, stack trace:<pre> {$trace} </pre>\n");
 }
Esempio n. 2
0
<?php

include_once "java/Java.inc";
$ex = new JavaException("java.lang.Exception", "bleh");
echo $ex->getMessage();
if ($ex->getMessage() == "") {
    die("test failed");
}
echo "\n---\n";
try {
    java("java.lang.System")->getProperties();
} catch (JavaException $e) {
    echo $e->getMessage();
    if ($e->getMessage() == "") {
        die("test failed");
    }
}
echo "\n---\n";