Skip to content

Commit 9cb5d31

Browse files
committed
[GR-17457] Use the NATIVE_PLATFORM option consistently over isNativeAccessAllowed()
PullRequest: truffleruby/3635
2 parents fc0d6dd + 48e0406 commit 9cb5d31

File tree

7 files changed

+13
-3
lines changed

7 files changed

+13
-3
lines changed

src/main/.checkstyle_checks.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@
255255
<property name="format" value='serialVersionUID'/>
256256
<property name="message" value='Use @SuppressWarnings("serial") instead.'/>
257257
</module>
258+
<module name="RegexpSinglelineJava">
259+
<property name="format" value='isNativeAccessAllowed\(\)'/>
260+
<property name="message" value='Use context.getOptions().NATIVE_PLATFORM instead.'/>
261+
</module>
258262
<module name="IllegalType">
259263
<!-- Use PrintStream instead of PrintWriter, PrintWriter does not consistently flush, even when writing \n.-->
260264
<property name="illegalClassNames" value="TruffleObject,DynamicObject,PrintWriter"/>

src/main/java/org/truffleruby/core/thread/ThreadManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public void startForeignThread(RubyThread rubyThread, Thread javaThread) {
408408

409409
public void start(RubyThread thread, Thread javaThread) {
410410
thread.thread = javaThread;
411-
thread.ioBuffer = context.getEnv().isNativeAccessAllowed() ? Pointer.getNullBuffer(context) : null;
411+
thread.ioBuffer = context.getOptions().NATIVE_PLATFORM ? Pointer.getNullBuffer(context) : null;
412412
registerThread(thread);
413413

414414
final RubyFiber rootFiber = thread.getRootFiber();

src/main/java/org/truffleruby/core/time/GetTimeZoneNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected TimeZoneAndName getTimeZone(
7171

7272
@NeverDefault
7373
protected Object getTZ() {
74-
if (getContext().getEnv().isNativeAccessAllowed()) {
74+
if (getContext().getOptions().NATIVE_PLATFORM) {
7575
return lookupEnvNode.call(coreLibrary().getENV(), "[]", FrozenStrings.TZ);
7676
} else {
7777
return nil;

src/main/java/org/truffleruby/extra/ffi/Pointer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public final class Pointer implements AutoCloseable, TruffleObject {
3939
public static final Pointer[] EMPTY_ARRAY = new Pointer[0];
4040

4141
public static void checkNativeAccess(RubyContext context) {
42-
if (!context.getEnv().isNativeAccessAllowed()) {
42+
if (!context.getOptions().NATIVE_PLATFORM) {
4343
CompilerDirectives.transferToInterpreterAndInvalidate();
4444
throw new RaiseException(
4545
context,

src/main/java/org/truffleruby/options/LanguageOptions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.oracle.truffle.api.TruffleLanguage.Env;
2121

2222
// @formatter:off
23+
// Checkstyle: stop
2324
public class LanguageOptions {
2425

2526
/** --no-home-provided=false */
@@ -732,4 +733,5 @@ public static boolean areOptionsCompatibleOrLog(TruffleLogger logger, LanguageOp
732733
return true;
733734
}
734735
}
736+
// Checkstyle: resume
735737
// @formatter:on

src/main/java/org/truffleruby/options/Options.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.oracle.truffle.api.TruffleLanguage.Env;
2323

2424
// @formatter:off
25+
// Checkstyle: stop
2526
public class Options {
2627

2728
/** --load-paths=StringArrayOptionType.EMPTY_STRING_ARRAY */
@@ -491,4 +492,5 @@ public Object fromDescriptor(OptionDescriptor descriptor) {
491492
}
492493

493494
}
495+
// Checkstyle: resume
494496
// @formatter:on

tool/generate-options.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def parse_reference_defaults(default)
163163
import com.oracle.truffle.api.TruffleLanguage.Env;
164164
165165
// @formatter:off
166+
// Checkstyle: stop
166167
public class <%= class_prefix %>Options {
167168
<% options.each do |o| %>
168169
/** --<%= o.name %>=<%= o.env_condition %><%= o.default %> */
@@ -209,6 +210,7 @@ def parse_reference_defaults(default)
209210
}
210211
<% end -%>
211212
}
213+
// Checkstyle: resume
212214
// @formatter:on
213215
JAVA
214216

0 commit comments

Comments
 (0)