Skip to content

Commit 9625921

Browse files
committed
Add jvmgetproperties op for access to JVM VM info
1 parent fff73cf commit 9625921

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,7 @@ QAST::OperationsJAST.map_classlib_core_op('nfarunalt', $TYPE_OPS, 'nfarunalt', [
23432343
QAST::OperationsJAST.map_classlib_core_op('exit', $TYPE_OPS, 'exit', [$RT_INT], $RT_INT);
23442344
QAST::OperationsJAST.map_classlib_core_op('sleep', $TYPE_OPS, 'sleep', [$RT_NUM], $RT_NUM);
23452345
QAST::OperationsJAST.map_classlib_core_op('getenvhash', $TYPE_OPS, 'getenvhash', [], $RT_OBJ, :tc);
2346+
QAST::OperationsJAST.map_classlib_core_op('jvmgetproperties', $TYPE_OPS, 'jvmgetproperties', [], $RT_OBJ, :tc);
23462347

23472348
# JVM-specific ops for compilation unit handling
23482349
QAST::OperationsJAST.map_classlib_core_op('compilejast', $TYPE_OPS, 'compilejast', [$RT_STR], $RT_OBJ, :tc);

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.HashMap;
3131
import java.util.List;
3232
import java.util.Map;
33+
import java.util.Properties;
3334
import java.util.Set;
3435
import java.util.concurrent.ThreadLocalRandom;
3536
import java.util.concurrent.TimeUnit;
@@ -3240,6 +3241,18 @@ public static SixModelObject getenvhash(ThreadContext tc) {
32403241

32413242
return res;
32423243
}
3244+
3245+
public static SixModelObject jvmgetproperties(ThreadContext tc) {
3246+
SixModelObject hashType = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.hashType;
3247+
SixModelObject strType = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.strBoxType;
3248+
SixModelObject res = hashType.st.REPR.allocate(tc, hashType.st);
3249+
3250+
Properties env = System.getProperties();
3251+
for (String envName : env.stringPropertyNames())
3252+
res.bind_key_boxed(tc, envName, box_s(env.getProperty(envName), strType, tc));
3253+
3254+
return res;
3255+
}
32433256

32443257
/* Exception related. */
32453258
public static void die_s_c(String msg, ThreadContext tc) {

0 commit comments

Comments
 (0)