Search in sources :

Example 1 with J9VMSystemPropertyPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9VMSystemPropertyPointer in project openj9 by eclipse.

the class J9JavaVMHelper method getSystemProperties.

public static Properties getSystemProperties(J9JavaVMPointer vm) throws CorruptDataException {
    Properties result = new Properties();
    Pool<J9VMSystemPropertyPointer> sysprops = Pool.fromJ9Pool(vm.systemProperties(), J9VMSystemPropertyPointer.class);
    Iterator<J9VMSystemPropertyPointer> syspropsIterator = sysprops.iterator();
    int count = 0;
    while (syspropsIterator.hasNext()) {
        J9VMSystemPropertyPointer prop = syspropsIterator.next();
        // Iterator may return null if corrupt data was found.
        if (prop != null) {
            String name = null;
            try {
                name = prop.name().getCStringAtOffset(0);
            } catch (CorruptDataException e) {
                name = "Corrupt System Property[" + count + "]";
            }
            String value = null;
            try {
                value = prop.value().getCStringAtOffset(0);
            } catch (CorruptDataException e) {
                value = "Corrupt Value";
            }
            result.setProperty(name, value);
        }
        count++;
    }
    return result;
}
Also used : J9VMSystemPropertyPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMSystemPropertyPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) Properties(java.util.Properties)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 J9VMSystemPropertyPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMSystemPropertyPointer)1 Properties (java.util.Properties)1