File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/vm/jvm/runtime/org/perl6/nqp/runtime Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 139
139
import org .perl6 .nqp .sixmodel .reprs .VMIterInstance ;
140
140
import org .perl6 .nqp .sixmodel .reprs .VMThreadInstance ;
141
141
142
+ import sun .misc .Unsafe ;
143
+
142
144
/**
143
145
* Contains complex operations that are more involved than the simple ops that the
144
146
* JVM makes available.
145
147
*/
146
148
public final class Ops {
149
+ /**
150
+ * Temporary workaround to avoid warnings about 'illegal reflective access'
151
+ * (taken from https://stackoverflow.com/a/46458447).
152
+ * Please note that this is needed for Rakudo, too.
153
+ * Once something else (e.g. VarHandle) is used instead
154
+ * of sun.misc.Unsafe this workaround can be removed.
155
+ */
156
+ public static void disableWarning () {
157
+ try {
158
+ Field theUnsafe = Unsafe .class .getDeclaredField ("theUnsafe" );
159
+ theUnsafe .setAccessible (true );
160
+ Unsafe u = (Unsafe )theUnsafe .get (null );
161
+
162
+ Class cls = Class .forName ("jdk.internal.module.IllegalAccessLogger" );
163
+ Field logger = cls .getDeclaredField ("logger" );
164
+ u .putObjectVolatile (cls , u .staticFieldOffset (logger ), null );
165
+ }
166
+ catch (Exception e ) {
167
+ // ignore (that's the raison d'être for this method)
168
+ }
169
+ }
170
+
147
171
/* I/O opcodes */
148
172
public static String print (String v , ThreadContext tc ) {
149
173
tc .gc .out .print (v );
You can’t perform that action at this time.
0 commit comments