本文整理匯總了Java中java.lang.RuntimeException類的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeException類的具體用法?Java RuntimeException怎麽用?Java RuntimeException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RuntimeException類屬於java.lang包,在下文中一共展示了RuntimeException類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testCausedFocusEventDeserialization
import java.lang.RuntimeException; //導入依賴的package包/類
private static void testCausedFocusEventDeserialization() throws
Exception {
for (int i = 0; i < causesIn.length; i++) {
final String causeIn = causesIn[i];
ObjectInputStream oi = new ObjectInputStream(new InputStream() {
int cnt = 0;
@Override
public int read() throws IOException {
if(cnt < data.length) {
return data[cnt++];
} else if(cnt == data.length){
cnt++;
return causeIn.length();
} else if(cnt - data.length - 1 < causeIn.length()) {
return causeIn.getBytes()[cnt++ - data.length - 1];
}
return -1;
}
});
FocusEvent ev = (FocusEvent) oi.readObject();
System.out.println(ev);
if(ev.getCause() != causesOut[i]) {
throw new RuntimeException("Wrong cause read :" +ev.getCause());
}
}
}
示例2: gcm_suppressUnreadCorrupt
import java.lang.RuntimeException; //導入依賴的package包/類
static void gcm_suppressUnreadCorrupt() throws Exception {
Cipher c;
byte[] read = new byte[200];
System.out.println("Running supressUnreadCorrupt test");
// Encrypt 100 bytes with AES/GCM/PKCS5Padding
byte[] ct = encryptedText("GCM", 100);
// Corrupt the encrypted message
ct = corruptGCM(ct);
// Create stream for decryption
CipherInputStream in = getStream("GCM", ct);
try {
in.close();
System.out.println(" Pass.");
} catch (IOException e) {
System.out.println(" Fail: " + e.getMessage());
throw new RuntimeException(e.getCause());
}
}
示例3: gcm_oneReadByte
import java.lang.RuntimeException; //導入依賴的package包/類
static void gcm_oneReadByte() throws Exception {
System.out.println("Running gcm_oneReadByte test");
// Encrypt 100 bytes with AES/GCM/PKCS5Padding
byte[] ct = encryptedText("GCM", 100);
// Create stream for decryption
CipherInputStream in = getStream("GCM", ct);
try {
in.read();
System.out.println(" Pass.");
} catch (Exception e) {
System.out.println(" Fail: " + e.getMessage());
throw new RuntimeException(e.getCause());
}
}
示例4: gcm_oneReadByteCorrupt
import java.lang.RuntimeException; //導入依賴的package包/類
static void gcm_oneReadByteCorrupt() throws Exception {
System.out.println("Running gcm_oneReadByteCorrupt test");
// Encrypt 100 bytes with AES/GCM/PKCS5Padding
byte[] ct = encryptedText("GCM", 100);
// Corrupt the encrypted message
ct = corruptGCM(ct);
// Create stream for decryption
CipherInputStream in = getStream("GCM", ct);
try {
in.read();
System.out.println(" Fail. No exception thrown.");
} catch (IOException e) {
Throwable ec = e.getCause();
if (ec instanceof AEADBadTagException) {
System.out.println(" Pass.");
} else {
System.out.println(" Fail: " + ec.getMessage());
throw new RuntimeException(ec);
}
}
}
示例5: cbc_shortStream
import java.lang.RuntimeException; //導入依賴的package包/類
static void cbc_shortStream() throws Exception {
Cipher c;
AlgorithmParameters params;
byte[] read = new byte[200];
System.out.println("Running cbc_shortStream");
// Encrypt 97 byte with AES/CBC/PKCS5Padding
byte[] ct = encryptedText("CBC", 97);
// Create stream with only 96 bytes of encrypted data
CipherInputStream in = getStream("CBC", ct, 96);
try {
int size = in.read(read);
in.close();
if (size != 80) {
throw new RuntimeException("Fail: CipherInputStream.read() " +
"returned " + size + ". Should have been 80");
}
System.out.println(" Pass.");
} catch (IOException e) {
System.out.println(" Fail: " + e.getMessage());
throw new RuntimeException(e.getCause());
}
}
示例6: cbc_shortRead400
import java.lang.RuntimeException; //導入依賴的package包/類
static void cbc_shortRead400() throws Exception {
System.out.println("Running cbc_shortRead400");
// Encrypt 400 byte with AES/CBC/PKCS5Padding
byte[] ct = encryptedText("CBC", 400);
// Create stream with encrypted data
CipherInputStream in = getStream("CBC", ct);
try {
in.read();
in.close();
System.out.println(" Pass.");
} catch (IOException e) {
System.out.println(" Fail: " + e.getMessage());
throw new RuntimeException(e.getCause());
}
}
示例7: cbc_shortRead600
import java.lang.RuntimeException; //導入依賴的package包/類
static void cbc_shortRead600() throws Exception {
System.out.println("Running cbc_shortRead600");
// Encrypt 600 byte with AES/CBC/PKCS5Padding
byte[] ct = encryptedText("CBC", 600);
// Create stream with encrypted data
CipherInputStream in = getStream("CBC", ct);
try {
in.read();
in.close();
System.out.println(" Pass.");
} catch (IOException e) {
System.out.println(" Fail: " + e.getMessage());
throw new RuntimeException(e.getCause());
}
}
示例8: main
import java.lang.RuntimeException; //導入依賴的package包/類
public static void main(String argv[]) throws InterruptedException, RuntimeException {
if (argv.length == 1 && argv[0].equals("buildagent")) {
buildAgent();
return;
}
if (inst == null) {
throw new RuntimeException("Instrumentation object was null");
}
new Thread() {
public void run() {
runTest();
}
}.start();
// Test that NCDFE is not thrown for anonymous class:
// ModifyAnonymous$InstanceMethodCallSiteApp$$Lambda$18
try {
ModifyAnonymous test = new ModifyAnonymous();
InstanceMethodCallSiteApp.test();
} catch (NoClassDefFoundError e) {
throw new RuntimeException("FAILED: NoClassDefFoundError thrown for " + e.getMessage());
}
System.out.println("PASSED: NoClassDefFound error not thrown");
}
示例9: testFocusEventDeserialization
import java.lang.RuntimeException; //導入依賴的package包/類
private static void testFocusEventDeserialization() throws
Exception {
ObjectInputStream oi = new ObjectInputStream(
new ByteArrayInputStream(dataOld));
FocusEvent ev = (FocusEvent)oi.readObject();
if(ev.getCause() != FocusEvent.Cause.UNKNOWN) {
throw new RuntimeException("Wrong cause in deserialized FocusEvent "
+ ev.getCause());
}
}
示例10: main
import java.lang.RuntimeException; //導入依賴的package包/類
public static void main(String argv[]) throws NoSuchFieldException, NoSuchMethodException {
if (argv.length == 1 && argv[0].equals("buildagent")) {
buildAgent();
return;
}
if (inst == null) {
throw new RuntimeException("Instrumentation object was null");
}
RedefineAnnotations test = new RedefineAnnotations();
test.testTransformAndVerify();
}
示例11: enc
import java.lang.RuntimeException; //導入依賴的package包/類
public static byte[] enc(Object obj) {
try {
ByteArrayOutputStream bout;
bout = new ByteArrayOutputStream();
new ObjectOutputStream(bout).writeObject(obj);
byte[] data = bout.toByteArray();
for (int i = 0; i < data.length - 5; i++) {
if (data[i] == 'j' && data[i + 1] == 'j' && data[i + 2] == 'j'
&& data[i + 3] == 'j' && data[i + 4] == 'j') {
System.arraycopy("javax".getBytes(), 0, data, i, 5);
}
}
return data;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例12: Capstone
import java.lang.RuntimeException; //導入依賴的package包/類
public Capstone(int arch, int mode) {
cs = (CS)Native.loadLibrary("capstone", CS.class);
int version = cs.cs_version(null, null);
if (version != (CS_API_MAJOR << 8) + CS_API_MINOR) {
throw new RuntimeException("Different API version between core & binding (CS_ERR_VERSION)");
}
this.arch = arch;
this.mode = mode;
ns = new NativeStruct();
ns.handleRef = new NativeLongByReference();
if (cs.cs_open(arch, mode, ns.handleRef) != CS_ERR_OK) {
throw new RuntimeException("ERROR: Wrong arch or mode");
}
ns.csh = ns.handleRef.getValue();
this.detail = CS_OPT_OFF;
this.diet = cs.cs_support(CS_SUPPORT_DIET);
}
示例13: invoke
import java.lang.RuntimeException; //導入依賴的package包/類
public Object invoke(Object reader, Object firstChar, Object opts, Object pendingForms){
PushbackReader r = (PushbackReader) reader;
pendingForms = ensurePending(pendingForms);
Object name = read(r, true, null, false, opts, pendingForms);
if (!(name instanceof Symbol))
throw new RuntimeException("Reader tag must be a symbol");
Symbol sym = (Symbol)name;
Object form = read(r, true, null, true, opts, pendingForms);
if(isPreserveReadCond(opts) || RT.suppressRead()) {
return TaggedLiteral.create(sym, form);
} else {
return sym.getName().contains(".") ? readRecord(form, sym, opts, pendingForms) : readTagged(form, sym, opts, pendingForms);
}
}
示例14: readTagged
import java.lang.RuntimeException; //導入依賴的package包/類
private Object readTagged(Object o, Symbol tag, Object opts, Object pendingForms){
ILookup data_readers = (ILookup)RT.DATA_READERS.deref();
IFn data_reader = (IFn)RT.get(data_readers, tag);
if(data_reader == null){
data_readers = (ILookup)RT.DEFAULT_DATA_READERS.deref();
data_reader = (IFn)RT.get(data_readers, tag);
if(data_reader == null){
IFn default_reader = (IFn)RT.DEFAULT_DATA_READER_FN.deref();
if(default_reader != null)
return default_reader.invoke(tag, o);
else
throw new RuntimeException("No reader function for tag " + tag.toString());
}
}
return data_reader.invoke(o);
}