com.sun.jdi.ByteValue Java Examples
The following examples show how to use
com.sun.jdi.ByteValue.
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: RemoteServices.java From netbeans with Apache License 2.0 | 5 votes |
private static ArrayReference createTargetBytes(VirtualMachine vm, byte[] bytes, ByteValue[] mirrorBytesCache) throws InvalidTypeException, ClassNotLoadedException, InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, UnsupportedOperationExceptionWrapper { ArrayType bytesArrayClass = getArrayClass(vm, "byte[]"); ArrayReference array = null; boolean disabledCollection = false; while (!disabledCollection) { array = ArrayTypeWrapper.newInstance(bytesArrayClass, bytes.length); try { ObjectReferenceWrapper.disableCollection(array); disabledCollection = true; } catch (ObjectCollectedExceptionWrapper ocex) { // Collected too soon, try again... } } List<Value> values = new ArrayList<Value>(bytes.length); for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; ByteValue mb = mirrorBytesCache[128 + b]; if (mb == null) { mb = VirtualMachineWrapper.mirrorOf(vm, b); mirrorBytesCache[128 + b] = mb; } values.add(mb); } ArrayReferenceWrapper.setValues(array, values); return array; }
Example #3
Source File: RemoteServices.java From netbeans with Apache License 2.0 | 5 votes |
private static ArrayReference createTargetBytes(VirtualMachine vm, byte[] bytes, ByteValue[] mirrorBytesCache) throws InvalidTypeException, ClassNotLoadedException, InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper, UnsupportedOperationExceptionWrapper { ArrayType bytesArrayClass = getArrayClass(vm, "byte[]"); ArrayReference array = null; boolean disabledCollection = false; while (!disabledCollection) { array = ArrayTypeWrapper.newInstance(bytesArrayClass, bytes.length); try { ObjectReferenceWrapper.disableCollection(array); disabledCollection = true; } catch (ObjectCollectedExceptionWrapper ocex) { // Collected too soon, try again... } } List<Value> values = new ArrayList<Value>(bytes.length); for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; ByteValue mb = mirrorBytesCache[128 + b]; if (mb == null) { mb = VirtualMachineWrapper.mirrorOf(vm, b); mirrorBytesCache[128 + b] = mb; } values.add(mb); } ArrayReferenceWrapper.setValues(array, values); return array; }
Example #4
Source File: RemoteServices.java From netbeans with Apache License 2.0 | 5 votes |
private static ArrayReference createTargetBytes(VirtualMachine vm, byte[] bytes, ByteValue[] mirrorBytesCache) throws InvalidTypeException, ClassNotLoadedException, InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper { ArrayType bytesArrayClass = getArrayClass(vm, "byte[]"); ArrayReference array = null; boolean disabledCollection = false; while (!disabledCollection) { array = ArrayTypeWrapper.newInstance(bytesArrayClass, bytes.length); try { ObjectReferenceWrapper.disableCollection(array); disabledCollection = true; } catch (ObjectCollectedExceptionWrapper ocex) { // Collected too soon, try again... } catch (UnsupportedOperationExceptionWrapper uex) { // Hope it will not be GC'ed... disabledCollection = true; } } List<Value> values = new ArrayList<Value>(bytes.length); for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; ByteValue mb = mirrorBytesCache[128 + b]; if (mb == null) { mb = VirtualMachineWrapper.mirrorOf(vm, b); mirrorBytesCache[128 + b] = mb; } values.add(mb); } ArrayReferenceWrapper.setValues(array, values); return array; }
Example #5
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()); }