com.sun.jdi.IntegerValue Java Examples

The following examples show how to use com.sun.jdi.IntegerValue. 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: AWTGrabHandler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void ungrabWindowFX(ClassType WindowClass, ObjectReference w, ThreadReference tr) throws Exception {
    // javafx.stage.Window w
    // w.focusGrabCounter
    // while (focusGrabCounter-- > 0) {
    //     w.impl_getPeer().ungrabFocus(); OR: w.impl_peer.ungrabFocus();
    // }
    Field focusGrabCounterField = WindowClass.fieldByName("focusGrabCounter");
    if (focusGrabCounterField == null) {
        logger.info("Unable to release FX X grab, no focusGrabCounter field in "+w);
        return ;
    }
    Value focusGrabCounterValue = w.getValue(focusGrabCounterField);
    if (!(focusGrabCounterValue instanceof IntegerValue)) {
        logger.info("Unable to release FX X grab, focusGrabCounter does not have an integer value in "+w);
        return ;
    }
    int focusGrabCounter = ((IntegerValue) focusGrabCounterValue).intValue();
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("Focus grab counter of "+w+" is: "+focusGrabCounter);
    }
    while (focusGrabCounter-- > 0) {
        //Method impl_getPeerMethod = WindowClass.concreteMethodByName("impl_getPeer", "");
        Field impl_peerField = WindowClass.fieldByName("impl_peer");
        if (impl_peerField == null) {
            logger.info("Unable to release FX X grab, no impl_peer field in "+w);
            return ;
        }
        ObjectReference impl_peer = (ObjectReference) w.getValue(impl_peerField);
        if (impl_peer == null) {
            continue;
        }
        InterfaceType TKStageClass = (InterfaceType) w.virtualMachine().classesByName("com.sun.javafx.tk.TKStage").get(0);
        Method ungrabFocusMethod = TKStageClass.methodsByName("ungrabFocus", "()V").get(0);
        impl_peer.invokeMethod(tr, ungrabFocusMethod, Collections.<Value>emptyList(), ObjectReference.INVOKE_SINGLE_THREADED);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("FX Window "+w+" was successfully ungrabbed.");
        }
    }
}
 
Example #2
Source File: DecisionProcedureGuidanceJDI.java    From jbse with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Object getValue(Symbolic origin) throws GuidanceException {
    final com.sun.jdi.Value val = (com.sun.jdi.Value) getJDIValue(origin);
    if (val instanceof IntegerValue) {
        return this.calc.valInt(((IntegerValue) val).intValue());
    } else if (val instanceof BooleanValue) {
        return this.calc.valBoolean(((BooleanValue) val).booleanValue());
    } else if (val instanceof CharValue) {
        return this.calc.valChar(((CharValue) val).charValue());
    } else if (val instanceof ByteValue) {
        return this.calc.valByte(((ByteValue) val).byteValue());
    } else if (val instanceof DoubleValue) {
        return this.calc.valDouble(((DoubleValue) val).doubleValue());
    } else if (val instanceof FloatValue) {
        return this.calc.valFloat(((FloatValue) val).floatValue());
    } else if (val instanceof LongValue) {
        return this.calc.valLong(((LongValue) val).longValue());
    } else if (val instanceof ShortValue) {
        return this.calc.valShort(((ShortValue) val).shortValue());
    } else if (val instanceof ObjectReference) {
        return val;
    } else { //val instanceof VoidValue || val == null
        return null;
    }
}
 
Example #3
Source File: VMTargetRemoteTest.java    From gravel with Apache License 2.0 6 votes vote down vote up
@Test
public void testEvaluate() throws Throwable {
	ObjectReference promise = remote.evaluateForked("3+4");
	ThreadReference thread = ((ThreadReference) remote.invokeMethod(
			promise, "thread"));
	Value result1 = remote.invokeMethod(promise, "result");
	Value ex = remote.invokeMethod(promise, "throwable");
	printThreadState();
	VMTargetStarter.sleep(100);
	printThreadState();

	boolean isFinished = ((BooleanValue) remote.invokeMethod(promise,
			"isFinished")).booleanValue();

	assertTrue(isFinished);
	ObjectReference result = (ObjectReference) remote.invokeMethod(promise,
			"result");
	IntegerValue intValue = (IntegerValue) remote.invokeMethod(result,
			"intValue");
	assertEquals(7, intValue.intValue());
}
 
Example #4
Source File: MirrorValuesTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testTargetMirrors() throws Exception {
    try {
        Utils.BreakPositions bp = Utils.getBreakPositions(System.getProperty ("test.dir.src") + 
                "org/netbeans/api/debugger/jpda/testapps/MirrorValuesApp.java");
        LineBreakpoint lb = bp.getLineBreakpoints().get(0);
        dm.addBreakpoint (lb);
        
        support = JPDASupport.attach (CLASS_NAME);

        support.waitState (JPDADebugger.STATE_STOPPED);  // breakpoint hit
        
        JPDADebugger debugger = support.getDebugger();
        
        Variable mirrorVar = debugger.createMirrorVar("Test");
        Value v = ((JDIVariable) mirrorVar).getJDIValue();
        assertTrue("Value "+v+" should be a String", v instanceof StringReference);
        assertEquals("Test", ((StringReference) v).value());
        
        Point p = new Point(-1, 1);
        mirrorVar = debugger.createMirrorVar(p);
        Object mp = mirrorVar.createMirrorObject();
        assertTrue("Correct point was created: "+mp, p.equals(mp));
        
        mirrorVar = debugger.createMirrorVar(1);
        v = ((JDIVariable) mirrorVar).getJDIValue();
        assertTrue("Value "+v+" should be an Integer object.",
                   (v.type() instanceof ClassType) && Integer.class.getName().equals(((ClassType) v.type()).name()));
        
        mirrorVar = debugger.createMirrorVar(1, true);
        v = ((JDIVariable) mirrorVar).getJDIValue();
        assertTrue("Value "+v+" should be an int.", v instanceof IntegerValue);
        assertEquals(((IntegerValue) v).value(), 1);
    } finally {
        support.doFinish ();
    }
}
 
Example #5
Source File: NumericFormatterTest.java    From java-debug with Eclipse Public License 1.0 4 votes vote down vote up
@Test
public void testValueOf() throws Exception {

    Value i = this.getLocalValue("i");
    Map<String, Object> options = formatter.getDefaultOptions();
    Value newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "111", newValue.toString());

    options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.HEX);

    newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "111", newValue.toString());

    options.put(NUMERIC_FORMAT_OPTION, NumericFormatEnum.OCT);
    newValue = formatter.valueOf(formatter.toString(i, options), i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "111", newValue.toString());


    newValue = formatter.valueOf("-12121212", i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "-12121212", newValue.toString());

    newValue = formatter.valueOf("0", i.type(), options);
    assertNotNull("NumericFormatter should be able to create integer by string.", newValue);
    assertTrue("Should create an integer value.", newValue instanceof IntegerValue);
    assertEquals("Should create an integer with right value.", "0", newValue.toString());

    VirtualMachine vm = getVM();

    newValue = formatter.valueOf("0", vm.mirrorOf(10.0f).type(), options);
    assertNotNull("NumericFormatter should be able to create float by string.", newValue);
    assertTrue("Should create an float value.", newValue instanceof FloatValue);
    assertEquals("Should create an float with right value.", "0.0", newValue.toString());

    newValue = formatter.valueOf("10.0", vm.mirrorOf(10.0).type(), options);
    assertNotNull("NumericFormatter should be able to create double by string.", newValue);
    assertTrue("Should create an double value.", newValue instanceof DoubleValue);
    assertEquals("Should create an double with right value.", "10.0", newValue.toString());

    newValue = formatter.valueOf("10", vm.mirrorOf((short)10).type(), options);
    assertNotNull("NumericFormatter should be able to create short by string.", newValue);
    assertTrue("Should create an short value.", newValue instanceof ShortValue);
    assertEquals("Should create an short with right value.", "10", newValue.toString());

    newValue = formatter.valueOf("10", vm.mirrorOf(10L).type(), options);
    assertNotNull("NumericFormatter should be able to create long by string.", newValue);
    assertTrue("Should create an long value.", newValue instanceof LongValue);
    assertEquals("Should create an long with right value.", "10", newValue.toString());

    newValue = formatter.valueOf("10", vm.mirrorOf((byte) 10).type(), options);
    assertNotNull("NumericFormatter should be able to create byte by string.", newValue);
    assertTrue("Should create an byte value.", newValue instanceof ByteValue);
    assertEquals("Should create an byte with right value.", "10", newValue.toString());
}
 
Example #6
Source File: VMRemoteTarget.java    From gravel with Apache License 2.0 4 votes vote down vote up
public int add(int x, int y) throws Throwable {
	Value resultMirror = invokeMethod("add", vm.mirrorOf(x), vm.mirrorOf(y));
	return ((IntegerValue) resultMirror).intValue();
}