Java Code Examples for com.sun.jdi.VirtualMachine#mirrorOf()

The following examples show how to use com.sun.jdi.VirtualMachine#mirrorOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TruffleBreakpointsHandler.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent evt) {
    final JSLineBreakpoint jsbp = (JSLineBreakpoint) evt.getSource();
    String propertyName = evt.getPropertyName();
    final TruffleBPMethods method;
    final List<? extends Value> args;
    final VirtualMachine vm = ((JPDADebuggerImpl) debugger).getVirtualMachine();
    if (vm == null) {
        return ;
    }
    switch (propertyName) {
        case JSLineBreakpoint.PROP_ENABLED:
            method = TruffleBPMethods.setEnabled;
            args = Collections.singletonList(vm.mirrorOf(jsbp.isEnabled()));
            break;
        case JSLineBreakpoint.PROP_CONDITION:
            method = TruffleBPMethods.setCondition;
            String condition = jsbp.getCondition();
            StringReference conditionRef = (condition != null) ? vm.mirrorOf(condition) : null;
            args = Collections.singletonList(conditionRef);
            break;
        case Breakpoint.PROP_HIT_COUNT_FILTER:
            method = TruffleBPMethods.setIgnoreCount;
            args = Collections.singletonList(vm.mirrorOf(getIgnoreCount(jsbp)));
            break;
        default:
            return ;
    }
    ((JPDADebuggerImpl) debugger).getRequestProcessor().post(new Runnable() {
        @Override
        public void run() {
            setBreakpointProperty(jsbp, method, args);
        }
    });
}
 
Example 2
Source File: NumericFormatter.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Value valueOf(String value, Type type, Map<String, Object> options) {
    VirtualMachine vm = type.virtualMachine();
    char signature0 = type.signature().charAt(0);
    if (signature0 == LONG
            || signature0 == INT
            || signature0 == SHORT
            || signature0 == BYTE) {
        long number = parseNumber(value);
        if (signature0 == LONG) {
            return vm.mirrorOf(number);
        } else if (signature0 == INT) {
            return vm.mirrorOf((int) number);
        } else if (signature0 == SHORT) {
            return vm.mirrorOf((short) number);
        } else if (signature0 == BYTE) {
            return vm.mirrorOf((byte) number);
        }
    } else if (hasFraction(signature0)) {
        double doubleNumber = parseFloatDouble(value);
        if (signature0 == DOUBLE) {
            return vm.mirrorOf(doubleNumber);
        } else {
            return vm.mirrorOf((float) doubleNumber);
        }
    }

    throw new UnsupportedOperationException(String.format("%s is not a numeric type.", type.name()));
}
 
Example 3
Source File: CharacterFormatter.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Value valueOf(String value, Type type, Map<String, Object> options) {
    VirtualMachine vm = type.virtualMachine();
    if (value == null) {
        return null;
    }
    if (value.length() == 3
            && value.startsWith("'")
            && value.endsWith("'")) {
        return type.virtualMachine().mirrorOf(value.charAt(1));
    }
    return vm.mirrorOf(value.charAt(0));
}
 
Example 4
Source File: DebugManagerHandler.java    From netbeans with Apache License 2.0 4 votes vote down vote up
void newPolyglotEngineInstance(ObjectReference engine, JPDAThreadImpl thread) {
    LOG.log(Level.FINE, "Engine created breakpoint hit: engine = {0} in thread = {1}", new Object[] { engine, thread.getThreadReference()});
    if (inited.compareAndSet(false, true)) {
        initDebuggerRemoteService(thread);
    }
    if (accessorClass == null) {
        // No accessor
        return ;
    }
    InvocationExceptionTranslated iextr = null;
    try {
        // Create an instance of JPDATruffleDebugManager in the backend
        // and submit breakpoints:
        thread.notifyMethodInvoking();
        VirtualMachine vm = ((JPDADebuggerImpl) debugger).getVirtualMachine();
        if (vm == null) {
            return ;
        }
        BooleanValue includeInternal = vm.mirrorOf(TruffleOptions.isLanguageDeveloperMode());
        BooleanValue doStepInto = vm.mirrorOf(isStepInto());
        Method debugManagerMethod = ClassTypeWrapper.concreteMethodByName(
                accessorClass,
                ACCESSOR_SET_UP_DEBUG_MANAGER_FOR,
                ACCESSOR_SET_UP_DEBUG_MANAGER_FOR_SGN);
        ThreadReference tr = thread.getThreadReference();
        List<Value> dmArgs = Arrays.asList(engine, includeInternal, doStepInto);
        LOG.log(Level.FINE, "Setting engine and step into = {0}", isStepInto());
        Object ret = ClassTypeWrapper.invokeMethod(accessorClass, tr, debugManagerMethod, dmArgs, ObjectReference.INVOKE_SINGLE_THREADED);
        if (ret instanceof ObjectReference) {   // Can be null when an existing debug manager is reused.
            //debugManager = (ObjectReference) ret;
            breakpointsHandler.submitBreakpoints(accessorClass, (ObjectReference) ret, thread);
        }
    } catch (VMDisconnectedExceptionWrapper vmd) {
    } catch (InvocationException iex) {
        iextr = new InvocationExceptionTranslated(iex, thread.getDebugger());
        Exceptions.printStackTrace(iex);
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    } finally {
        thread.notifyMethodInvokeDone();
    }
    if (iextr != null) {
        iextr.preload(thread);
        Exceptions.printStackTrace(iextr);
    }
}
 
Example 5
Source File: BooleanFormatter.java    From java-debug with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Value valueOf(String value, Type type, Map<String, Object> options) {
    VirtualMachine vm = type.virtualMachine();
    return vm.mirrorOf(Boolean.parseBoolean(value));
}