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