Skip to content

Commit

Permalink
rename files to saner names
Browse files Browse the repository at this point in the history
  • Loading branch information
lytles@takashi committed Sep 25, 2018
1 parent cceddeb commit f7cb77e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/com/nqzero/unflect/Demo8.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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 java.io.FileDescriptor;
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)
Expand Down Expand Up @@ -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<ClassLoader,String> app = build(cl,"ucp")
.chain("path")
Expand Down
2 changes: 1 addition & 1 deletion src/com/nqzero/unflect/DemoNormal.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/com/nqzero/unflect/DemoUnflect.java
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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<ClassLoader,String> app = build(cl,"ucp")
.chain("path")
Expand Down
Original file line number Diff line number Diff line change
@@ -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<TT,VV> {
public abstract class Safer<TT,VV> {


public interface Meth<VV> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Module> 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) {
Expand Down
14 changes: 8 additions & 6 deletions src/com/nqzero/unflect/Unflect.java
Original file line number Diff line number Diff line change
@@ -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<TT,VV> extends SaferUnsafe<TT,VV> {
public class Unflect<TT,VV> extends Safer<TT,VV> {
public static final String splitChar = "\\.";

static Unflect<AccessibleObject,Boolean> override = build(AccessibleObject.class,"override");
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -206,7 +208,7 @@ protected Class klass() {
else return field.getType();
}

public class Linked extends SaferUnsafe<TT,VV> {
public class Linked extends Safer<TT,VV> {
int [] rows;
protected long offset() {
return Unflect.this.last.addy(rows);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f7cb77e

Please sign in to comment.