diff --git a/src/com/nqzero/unflect/Demo8.java b/src/com/nqzero/unflect/Demo8.java index fad950d..c8c17ec 100644 --- a/src/com/nqzero/unflect/Demo8.java +++ b/src/com/nqzero/unflect/Demo8.java @@ -1,6 +1,6 @@ package com.nqzero.unflect; -import com.nqzero.unflect.SaferUnsafe.Meth; +import com.nqzero.unflect.Safer.Meth; import static com.nqzero.unflect.Unflect.getField; import static com.nqzero.unflect.Unflect.unLog; import static com.nqzero.unflect.Unflect.build; @@ -8,7 +8,7 @@ import java.io.RandomAccessFile; import java.lang.reflect.Field; import java.net.URL; -import static com.nqzero.unflect.UnsafeWrapper.uu; +import static com.nqzero.unflect.Unsafer.uu; import static com.nqzero.unflect.Unflect.setAccessible; // duplicate the full demo since it uses java 11 classes for some of the tests (which are removed here) @@ -54,7 +54,7 @@ public Object meth(Object arg0,long arg1) { for (int jj=0; jj < ii; jj++) System.out.format("ufd %2d: %4d\n",jj,vals[jj]); - ClassLoader cl = SaferUnsafe.class.getClassLoader(); + ClassLoader cl = Safer.class.getClassLoader(); Unflect app = build(cl,"ucp") .chain("path") diff --git a/src/com/nqzero/unflect/DemoNormal.java b/src/com/nqzero/unflect/DemoNormal.java index ae00a39..11d6a14 100644 --- a/src/com/nqzero/unflect/DemoNormal.java +++ b/src/com/nqzero/unflect/DemoNormal.java @@ -1,6 +1,6 @@ package com.nqzero.unflect; -import static com.nqzero.unflect.SaferUnsafe.logger; +import static com.nqzero.unflect.Safer.logger; import java.io.FileDescriptor; import java.io.RandomAccessFile; import java.lang.reflect.Field; diff --git a/src/com/nqzero/unflect/DemoUnflect.java b/src/com/nqzero/unflect/DemoUnflect.java index d718bbc..156a5ec 100644 --- a/src/com/nqzero/unflect/DemoUnflect.java +++ b/src/com/nqzero/unflect/DemoUnflect.java @@ -1,17 +1,17 @@ package com.nqzero.unflect; -import com.nqzero.unflect.SaferUnsafe.Meth; +import com.nqzero.unflect.Safer.Meth; import static com.nqzero.unflect.Unflect.getField; import static com.nqzero.unflect.Unflect.unLog; import static com.nqzero.unflect.Unflect.build; -import static com.nqzero.unflect.SaferUnsafe.logger; +import static com.nqzero.unflect.Safer.logger; import java.io.FileDescriptor; import java.io.RandomAccessFile; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.URL; -import static com.nqzero.unflect.UnsafeWrapper.uu; +import static com.nqzero.unflect.Unsafer.uu; import static com.nqzero.unflect.Unflect.setAccessible; public class DemoUnflect { @@ -65,7 +65,7 @@ public Object meth(Object arg0,long arg1) { for (int jj=0; jj < ii; jj++) System.out.format("ufd %2d: %4d\n",jj,vals[jj]); - ClassLoader cl = SaferUnsafe.class.getClassLoader(); + ClassLoader cl = Safer.class.getClassLoader(); Unflect app = build(cl,"ucp") .chain("path") diff --git a/src/com/nqzero/unflect/SaferUnsafe.java b/src/com/nqzero/unflect/Safer.java similarity index 98% rename from src/com/nqzero/unflect/SaferUnsafe.java rename to src/com/nqzero/unflect/Safer.java index 47d1d87..ddfb096 100644 --- a/src/com/nqzero/unflect/SaferUnsafe.java +++ b/src/com/nqzero/unflect/Safer.java @@ -1,12 +1,12 @@ package com.nqzero.unflect; -import static com.nqzero.unflect.UnsafeWrapper.uu; +import static com.nqzero.unflect.Unsafer.uu; -public abstract class SaferUnsafe { +public abstract class Safer { public interface Meth { diff --git a/src/com/nqzero/unflect/Support11.java b/src/com/nqzero/unflect/Support9.java similarity index 86% rename from src/com/nqzero/unflect/Support11.java rename to src/com/nqzero/unflect/Support9.java index 3f579f6..cd92d8d 100644 --- a/src/com/nqzero/unflect/Support11.java +++ b/src/com/nqzero/unflect/Support9.java @@ -5,17 +5,17 @@ import java.util.HashSet; import static com.nqzero.unflect.Unflect.setAccessible; -public class Support11 { +public class Support9 { public static void godMode() { try { Method export = Module.class.getDeclaredMethod("implAddOpens",String.class); setAccessible(export); HashSet modules = new HashSet(); - Module base = SaferUnsafe.class.getModule(); + Module base = Safer.class.getModule(); if (base.getLayer() != null) modules.addAll(base.getLayer().modules()); modules.addAll(ModuleLayer.boot().modules()); - for (ClassLoader cl = SaferUnsafe.class.getClassLoader(); cl != null; cl = cl.getParent()) { + for (ClassLoader cl = Safer.class.getClassLoader(); cl != null; cl = cl.getParent()) { modules.add(cl.getUnnamedModule()); } for (Module module : modules) { diff --git a/src/com/nqzero/unflect/Unflect.java b/src/com/nqzero/unflect/Unflect.java index d94a47a..4076367 100644 --- a/src/com/nqzero/unflect/Unflect.java +++ b/src/com/nqzero/unflect/Unflect.java @@ -1,13 +1,13 @@ package com.nqzero.unflect; -import com.nqzero.unflect.SaferUnsafe.Meth; +import com.nqzero.unflect.Safer.Meth; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; -import static com.nqzero.unflect.UnsafeWrapper.uu; +import static com.nqzero.unflect.Unsafer.uu; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -public class Unflect extends SaferUnsafe { +public class Unflect extends Safer { public static final String splitChar = "\\."; static Unflect override = build(AccessibleObject.class,"override"); @@ -30,8 +30,10 @@ public static void unLog() { public static void godMode() { try { + // this will fail on java 8 and lower + // but load with at least java 9-11 Class base = Unflect.class; - Class klass = base.getClassLoader().loadClass(base.getPackageName() + ".Support11"); + Class klass = base.getClassLoader().loadClass(base.getPackageName() + ".Support9"); Method method = klass.getMethod("godMode"); method.invoke(null); } @@ -151,7 +153,7 @@ public static void main(String[] args) throws Exception { long scale; Unflect chain; Unflect last = this; - Unflect first = null; + Unflect first; Object base; int rowPosition; boolean isKnown = true; @@ -206,7 +208,7 @@ protected Class klass() { else return field.getType(); } - public class Linked extends SaferUnsafe { + public class Linked extends Safer { int [] rows; protected long offset() { return Unflect.this.last.addy(rows); diff --git a/src/com/nqzero/unflect/UnsafeWrapper.java b/src/com/nqzero/unflect/Unsafer.java similarity index 93% rename from src/com/nqzero/unflect/UnsafeWrapper.java rename to src/com/nqzero/unflect/Unsafer.java index d65b311..762f28e 100644 --- a/src/com/nqzero/unflect/UnsafeWrapper.java +++ b/src/com/nqzero/unflect/Unsafer.java @@ -2,7 +2,7 @@ import java.lang.reflect.Field; -public class UnsafeWrapper { +public class Unsafer { private static Object getField(Class klass,String name) { try { Field f = klass.getDeclaredField(name);