Skip to content

Commit

Permalink
rename artifact and split demos out into a separate project
Browse files Browse the repository at this point in the history
  • Loading branch information
lytles@takashi committed Sep 25, 2018
1 parent f7cb77e commit 05fccfe
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 21 deletions.
35 changes: 35 additions & 0 deletions demo/demo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /bin/bash


if [ -n "$MAVEN_HOME" ]; then
echo "adding MAVEN_HOME to path: $MAVEN_HOME/bin"
PATH="$MAVEN_HOME/bin:$PATH"
fi

yes "" | head
JAVA_HOME=$java9 mvn clean package
cp=$(mvn -q dependency:build-classpath -Dmdep.outputFile=/dev/fd/1)
echo "classpath: $cp"


yes "" | head
echo "demo unflect for java 8 - 7, 8, 9, 10, 11"
for ii in $java7 $java8 $java9 $java10 $java11; do
$ii/bin/java -cp target/classes:$cp demo.Demo8
done

yes "" | head
echo "demo unflect - 9, 10, 11"
for ii in $java9 $java10 $java11; do
$ii/bin/java -cp target/classes:$cp demo.DemoUnflect
done

yes "" | head
echo "demo normal without godmode - should fail"
$java9/bin/java -cp target/classes:$cp demo.DemoNormal

yes "" | head
echo "demo normal with godmode"
$java9/bin/java -cp target/classes:$cp com.nqzero.unflect.Unflect demo.DemoNormal

yes "" | head
21 changes: 21 additions & 0 deletions demo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.nqzero</groupId>
<artifactId>demo-reflect</artifactId>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>com.nqzero</groupId>
<artifactId>reflect</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.nqzero.unflect;
package demo;

import com.nqzero.unflect.*;
import com.nqzero.unflect.Safer.Meth;
import static com.nqzero.unflect.Unflect.getField;
import static com.nqzero.unflect.Unflect.unLog;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.nqzero.unflect;
package demo;

import static com.nqzero.unflect.Safer.logger;
import com.nqzero.unflect.*;
import java.io.FileDescriptor;
import java.io.RandomAccessFile;
import java.lang.reflect.Field;
Expand All @@ -13,7 +13,7 @@ public static void main(String[] args) throws Exception {
FileDescriptor fd = raf.getFD();
Field field = FileDescriptor.class.getDeclaredField("fd");
Class log = Class.forName("jdk.internal.module.IllegalAccessLogger");
System.out.println("logger: " + logger(false));
System.out.println("logger: " + DemoUnflect.logger(false));
try {
field.setAccessible(true);
vals[ii++] = field.getInt(fd);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.nqzero.unflect;
package demo;

import com.nqzero.unflect.*;
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.Safer.logger;
import java.io.FileDescriptor;
import java.io.RandomAccessFile;
import java.lang.reflect.AccessibleObject;
Expand All @@ -15,6 +15,17 @@
import static com.nqzero.unflect.Unflect.setAccessible;

public class DemoUnflect {
static Object logger(boolean expected) {
Object obj = null;
try {
obj = jdk.internal.module.IllegalAccessLogger.illegalAccessLogger();
}
catch (Throwable ex) {}
if (expected & obj==null)
throw new RuntimeException("mismatch: " + obj);
return obj;
}

public static void main(String[] args) throws Exception {
int [] vals = new int[10];
int ii = 0;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.nqzero</groupId>
<artifactId>srlutils-demo-unsafe</artifactId>
<artifactId>reflect</artifactId>
<version>0.1</version>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down
14 changes: 0 additions & 14 deletions src/com/nqzero/unflect/Safer.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,5 @@ public final long getAndSetLong(TT o,long newValue) {
public final VV getAndSetObject(TT o,VV newValue) {
return (VV) uu.getAndSetObject(resolve(o),offset(),newValue);
}


static Object logger(boolean expected) {
Object obj = null;
try {
obj = jdk.internal.module.IllegalAccessLogger.illegalAccessLogger();
}
catch (Throwable ex) {}
if (expected & obj==null)
throw new RuntimeException("mismatch: " + obj);
return obj;
}



}

0 comments on commit 05fccfe

Please sign in to comment.