com.sun.jdi.DoubleValue Java Examples
The following examples show how to use
com.sun.jdi.DoubleValue.
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: DecisionProcedureGuidanceJDI.java From jbse with GNU General Public License v3.0 | 6 votes |
@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 #2
Source File: RemoteFXScreenshot.java From netbeans with Apache License 2.0 | 5 votes |
private static Rectangle convertBounds(ObjectReference bounds) { ClassType boundsClass = (ClassType)bounds.referenceType(); Field minX = boundsClass.fieldByName("minX"); Field minY = boundsClass.fieldByName("minY"); Field width = boundsClass.fieldByName("width"); Field height = boundsClass.fieldByName("height"); return new Rectangle(((DoubleValue)bounds.getValue(minX)).intValue(), ((DoubleValue)bounds.getValue(minY)).intValue(), ((DoubleValue)bounds.getValue(width)).intValue(), ((DoubleValue)bounds.getValue(height)).intValue() ); }
Example #3
Source File: DebugTest.java From Recaf with MIT License | 5 votes |
@Test @Timeout(FAIL_TIMEOUT_SECONDS) public void testInvokeStatic() { // Invoke a static method on the JVM. // - Must wait until the class is loaded, so we execute this on the prepare class event double[] value = { -1 }; ClassPrepareRequest request = vm.prepare("calc.Calculator", e -> { try { Value v = vm.invokeStatic("calc.Calculator", "evaluate", "(Ljava/lang/String;)D", "9+1"); value[0] = ((DoubleValue) v).value(); } catch(JdiInvokeException ex) { fail(ex); } }); // This line is VERY important when calling "vm.invokeStatic" in this context // - Without it, the target VM will hang forever request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); request.enable(); // Run / finish calculator. This should cause the Calculator class to load. queue(() -> { sendInput("0\n"); close(); }); execute(); // Assertions assertEquals(10.0, value[0]); }
Example #4
Source File: NumericFormatterTest.java From java-debug with Eclipse Public License 1.0 | 4 votes |
@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()); }