Skip to content

Commit

Permalink
JEP 400
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Sep 21, 2024
1 parent 0715739 commit 49214a5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package xyz.wagyourtail.jvmdg.j18.stub.java_base;

import xyz.wagyourtail.jvmdg.version.Ref;
import xyz.wagyourtail.jvmdg.version.Stub;

import java.util.Properties;

/**
* JEP 400
*/
public class J_L_System {

@Stub(ref = @Ref("java/lang/System"))
public static String getProperty(String key) {
if (key.equals("native.encoding")) {
// check if native.encoding is actually set
var prop = System.getProperty(key);
if (prop != null) {
return prop;
}
// return fallback
return System.getProperty("file.encoding");
}
return System.getProperty(key);
}

@Stub(ref = @Ref("java/lang/System"))
public static Properties getProperties() {
var props = System.getProperties();
if (!props.containsKey("native.encoding")) {
props.put("native.encoding", props.getProperty("file.encoding"));
}
return props;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import xyz.wagyourtail.jvmdg.version.Stub;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;

public class J_N_C_Charset {
Expand All @@ -17,4 +18,13 @@ public static Charset forName(String name, Charset defaultCharset) {
}
}

/**
* JEP 400
*/
@Stub(ref = @Ref("java/nio/charset/Charset"))
public static Charset defaultCharset() {
return StandardCharsets.UTF_8;
}


}

0 comments on commit 49214a5

Please sign in to comment.