Example usage for java.lang StackOverflowError StackOverflowError

List of usage examples for java.lang StackOverflowError StackOverflowError

Introduction

In this page you can find the example usage for java.lang StackOverflowError StackOverflowError.

Prototype

public StackOverflowError(String s) 

Source Link

Document

Constructs a StackOverflowError with the specified detail message.

Usage

From source file:com.laxser.blitz.web.instruction.InstructionExecutorImpl.java

/**
 * @param inv//  w  ww .  j  a  v a 2 s  . c  om
 * @param instruction
 * @return
 * @throws StackOverflowError
 */
private Instruction translatesToInstructionObject(InvocationBean inv, Object instruction)
        throws StackOverflowError {
    int count = 0;
    while (!(instruction instanceof Instruction)) {
        if (count++ > 50) {
            throw new StackOverflowError("Unable to parse the instruction to an"
                    + " Instruction object less than " + count + " times. Is the instruction"
                    + " that returned by your controller" + " action is right?");
        }

        if (Thread.interrupted() || instruction == null) {
            return null;
        } else {
            if (instruction.getClass() != String.class
                    && !ClassUtils.isPrimitiveOrWrapper(instruction.getClass())
                    && instruction.getClass().getComponentType() == null
                    && instruction.getClass().getAnnotation(Component.class) != null) {
                SpringUtils.autowire(instruction, inv.getApplicationContext());
            }
            instruction = parseInstruction(inv, instruction);
        }
    }
    return (Instruction) instruction;
}

From source file:com.google.acre.script.HostEnv.java

@SuppressWarnings("null")
@JSFunction//  www . j  a  v a2 s  . c om
public String dev_test_internal(String name) {
    // the js entry point shouldn't be visible to user scripts
    // unless developer mode is enabled, but double-check it
    // here too.
    if (!ACRE_DEVELOPER_MODE) {
        return "";
    }

    if (name.equals("OutOfMemoryError")) {
        throw new OutOfMemoryError("this is an OutOfMemoryError message");
    }
    if (name.equals("StackOverflowError")) {
        throw new StackOverflowError("this is an StackOverflowError message");
    }
    if (name.equals("ThreadDeath")) {
        throw new ThreadDeath();
    }
    if (name.equals("RuntimeException")) {
        throw new RuntimeException("this is a RuntimeException message");
    }
    if (name.equals("Error")) {
        throw new Error("this is an Error message");
    }
    if (name.equals("AcreScriptError")) {
        throw new AcreScriptError("AcreScriptError - faked script was taking too long");
    }
    if (name.equals("NullPointerException")) {
        Object n = null;
        n.toString();
    }

    // not really "throw", so the different naming style is deliberate
    if (name.equals("java_infinite_loop")) {
        boolean a = true;
        while (a) {
        }
    }

    // quick-and-dirty reflecton of options to this function
    //  so they aren't duplicated in test code
    if (name.equals("list")) {
        return "OutOfMemoryError StackOverflowError ThreadDeath RuntimeException Error AcreScriptError NullPointerException java_infinite_loop";
    }

    // TODO add more options to test potential java failures
    //  log_spew   to try to overwhelm the log system
    // ...

    // if you add more cases, update the "list" case above too!

    return "";
}