本文整理汇总了Java中java.rmi.MarshalException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java MarshalException.getCause方法的具体用法?Java MarshalException.getCause怎么用?Java MarshalException.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.rmi.MarshalException
的用法示例。
在下文中一共展示了MarshalException.getCause方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.rmi.MarshalException; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 6332349\n");
Ping impl = new PingImpl();
Reference<?> ref = new WeakReference<Ping>(impl);
try {
Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
Object notSerializable = new Object();
stub.ping(impl, null);
try {
stub.ping(impl, notSerializable);
} catch (MarshalException e) {
if (e.getCause() instanceof NotSerializableException) {
System.err.println("ping invocation failed as expected");
} else {
throw e;
}
}
} finally {
UnicastRemoteObject.unexportObject(impl, true);
}
impl = null;
// Might require multiple calls to System.gc() for weak-references
// processing to be complete. If the weak-reference is not cleared as
// expected we will hang here until timed out by the test harness.
while (true) {
System.gc();
Thread.sleep(20);
if (ref.get() == null) {
break;
}
}
System.err.println("TEST PASSED");
}
示例2: main
import java.rmi.MarshalException; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
System.err.println("\nRegression test for bug 6332349\n");
Ping impl = new PingImpl();
Reference<?> ref = new WeakReference<Ping>(impl);
try {
Ping stub = (Ping) UnicastRemoteObject.exportObject(impl, 0);
Object notSerializable = new Object();
stub.ping(impl, null);
try {
stub.ping(impl, notSerializable);
} catch (MarshalException e) {
if (e.getCause() instanceof NotSerializableException) {
System.err.println("ping invocation failed as expected");
} else {
throw e;
}
}
} finally {
UnicastRemoteObject.unexportObject(impl, true);
}
impl = null;
System.gc();
if (ref.get() != null) {
throw new Error("TEST FAILED: impl not garbage collected");
}
System.err.println("TEST PASSED");
}