-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Kemper
authored and
Christian Kemper
committed
Nov 26, 2019
0 parents
commit 17cec25
Showing
46 changed files
with
891 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group = 'de.fiduciagad.tools.BCEL' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '1.8' | ||
|
||
dependencies { | ||
implementation 'org.apache.bcel:bcel:5.2' | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package de.fiduciagad.bcel; | ||
|
||
import org.apache.bcel.classfile.ClassParser; | ||
import org.apache.bcel.classfile.JavaClass; | ||
|
||
/** | ||
* | ||
* @author xgadkem | ||
*/ | ||
public class Main { | ||
|
||
/** | ||
* @param args | ||
*/ | ||
public static void main(String[] args) { | ||
try { | ||
|
||
System.out.println(); | ||
|
||
printClassVersion("C:\\TEMP\\client.jar", "de/gad/b21/Test.class"); | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static void printClassVersion(String jarfile, String classfile) throws Exception { | ||
ClassParser cp = new ClassParser(jarfile, classfile); | ||
JavaClass clazz1 = cp.parse(); | ||
System.out.println(jarfile + " -> " + classfile); | ||
System.out.println("Major: " + clazz1.getMajor()); | ||
System.out.println("Minor: " + clazz1.getMinor()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
plugins { | ||
id 'java' | ||
id 'application' | ||
id 'cpp' | ||
} | ||
|
||
mainClassName = 'de.gad.jni.SayHello' | ||
|
||
group = 'de.fiduciagad.tools.JNI' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '1.8' | ||
|
||
println "Building on OS: " + System.properties['os.name'] | ||
println "Using JDK: " + System.properties['java.home'] | ||
|
||
dependencies { | ||
testImplementation 'junit:junit:4.12' | ||
} | ||
|
||
|
||
test { | ||
systemProperty "java.library.path", file("${buildDir}/libs/hello/shared").absolutePath | ||
} | ||
|
||
|
||
model { | ||
components { | ||
sayHello(NativeLibrarySpec) { | ||
sources { | ||
cpp { | ||
source { | ||
srcDir 'src/main/jni' | ||
include "**/*.cpp" | ||
} | ||
exportedHeaders { | ||
srcDirs "${org.gradle.internal.jvm.Jvm.current().javaHome}/include", "${org.gradle.internal.jvm.Jvm.current().javaHome}/include/darwin" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
test.dependsOn 'sayHelloSharedLibrary' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.gad.jni; | ||
|
||
public class SayHello { | ||
|
||
static { | ||
System.out.println("Load lib from classloader " + SayHello.class.getClassLoader()); | ||
try { | ||
System.loadLibrary("sayHello"); | ||
} | ||
catch (Throwable e) { | ||
System.err.println("Ignoring exception " + e); | ||
} | ||
} | ||
|
||
private native String sayHello(String name); | ||
|
||
public String say(String name) { | ||
return sayHello(name); | ||
} | ||
|
||
@Override | ||
protected void finalize() throws Throwable { | ||
System.err.println("I'm finalized!!!"); | ||
} | ||
|
||
public static void main(String[] args) { | ||
try { | ||
SayHello hello = new SayHello(); | ||
for (int i = 0; i < 50; ++i) { | ||
hello.say("Roundtrip call " + i); | ||
} | ||
System.out.println(hello.sayHello("xgadkem")); | ||
// Thread.sleep(5000); | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package de.gad.jni; | ||
|
||
public class SayHelloAdapter { | ||
|
||
private final SayHello hello = new SayHello(); | ||
|
||
public String sayHello(String name) { | ||
return hello.say(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "de_gad_jni_SayHello.h" | ||
|
||
#include <string> | ||
|
||
using namespace std; | ||
|
||
JNIEXPORT jstring JNICALL Java_de_gad_jni_SayHello_sayHello(JNIEnv* env, jobject obj, jstring name) { | ||
|
||
const char* c_str = env->GetStringUTFChars(name, NULL); | ||
string c_name(c_str); | ||
|
||
env->ReleaseStringUTFChars(name, c_str); | ||
|
||
c_name = "Hello " + c_name + " from the native code!"; | ||
|
||
return env->NewStringUTF(c_name.c_str()); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.gad.jni; | ||
|
||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class SayHelloTest { | ||
|
||
@Test | ||
public void testHello() throws Exception | ||
{ | ||
SayHello hello = new SayHello(); | ||
String spoken = hello.say("Lutz"); | ||
Assert.assertEquals("Hello Lutz from the native code!", spoken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group = 'de.fiduciagad.tools.backtracking' | ||
version = '0.0.1-SNAPSHOT' | ||
sourceCompatibility = '1.8' | ||
|
||
dependencies { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package backtracking; | ||
|
||
public class Labyrinth { | ||
public char [][] lab = {{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'}, | ||
{' ',' ','*',' ','*','*','*','*','*','*','*','*','*','*','*','*','*','*','K','*'}, | ||
{'*',' ',' ',' ','*','*','*','*','*','*','*','*','*','*','*','*','*','*',' ','*'}, | ||
{'*',' ','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*',' ','*'}, | ||
{'*',' ',' ',' ',' ',' ',' ',' ','*',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','*'}, | ||
{'*',' ','*','*','*','*','*','*','*',' ','*','*','*','*','*','*','*','*',' ','*'}, | ||
{'*',' ','*','*',' ','*','*','*','*',' ','*','*','*','*','*','*','*','*',' ','*'}, | ||
{'*',' ',' ',' ',' ','*','*','*','*',' ','*','*',' ',' ',' ',' ','*','*',' ','*'}, | ||
{'*',' ','*','*','*','*','*','*','*',' ','*','*',' ','*','*',' ','*','*',' ','*'}, | ||
{'*',' ','*','*','*','*',' ',' ',' ',' ','*','*','*','*','*',' ','*','*',' ','*'}, | ||
{'*',' ','*','*','*','*',' ','*',' ',' ','*','*','*','*','*',' ','*','*',' ','*'}, | ||
{'*',' ','*','*','*','*',' ','*',' ',' ',' ',' ',' ',' ',' ',' ','*','*',' ','*'}, | ||
{'*',' ','*','*','*','*',' ','*',' ','*','*','*','*','*','*','*',' ',' ',' ','*'}, | ||
{'*',' ',' ',' ',' ','*',' ','*',' ','*','*','*','*','*',' ','*','*','*',' ','*'}, | ||
{'*','*','*','*',' ','*',' ','*',' ',' ',' ',' ',' ','*',' ',' ',' ',' ',' ','*'}, | ||
{'*',' ',' ',' ',' ','*',' ','*','*','*','*','*',' ','*','*','*','*','*',' ','*'}, | ||
{'*','*',' ','*',' ',' ',' ','*','*','*','*','*',' ','*','*','*','*','*',' ','*'}, | ||
{'*','*',' ','*','*','*','*','*','*','*','*','*',' ','*','*','*','*','*',' ','*'}, | ||
{'*',' ',' ',' ',' ',' ','*','*','*','*','*','*',' ',' ',' ',' ',' ',' ',' ','*'}, | ||
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*' ,'*','*'}, | ||
}; | ||
public Labyrinth() { | ||
} | ||
|
||
public void ausgeben(){ | ||
for (int i = 0; i<lab.length;i++){ | ||
for(int j = 0; j<lab[i].length;j++){ | ||
System.out.print(lab[i][j]); | ||
} | ||
System.out.println(""); | ||
} | ||
} | ||
public boolean rechtsFrei(int posX, int posY){ | ||
try { | ||
|
||
if(lab[posX+1][posY] != '*' && lab[posX+1][posY] != 'M') | ||
return true; | ||
else | ||
return false; | ||
} | ||
catch (Exception ex) { | ||
return false; | ||
} | ||
} | ||
public boolean linksFrei(int posX, int posY){ | ||
try { | ||
if(lab[posX-1][posY] != '*' && lab[posX-1][posY] != 'M') | ||
return true; | ||
else | ||
return false; | ||
} | ||
catch (Exception ex) { | ||
return false; | ||
} | ||
|
||
} | ||
public boolean untenFrei(int posX, int posY){ | ||
try { | ||
if(lab[posX][posY+1] != '*' && lab[posX][posY+1] != 'M') | ||
return true; | ||
else | ||
return false; | ||
} | ||
catch (Exception ex) { | ||
return false; | ||
} | ||
|
||
} | ||
public boolean obenFrei(int posX, int posY){ | ||
try { | ||
if(lab[posX][posY-1] != '*' && lab[posX][posY-1] != 'M') | ||
return true; | ||
else | ||
return false; | ||
} | ||
catch (Exception ex) { | ||
return false; | ||
} | ||
} | ||
|
||
public boolean gefunden(int posX, int posY){ | ||
try { | ||
if(lab[posX][posY] == 'K') | ||
return true; | ||
else | ||
return false; | ||
} | ||
catch (Exception ex) { | ||
return false; | ||
} | ||
} | ||
|
||
public void setzteMaus(int posX, int posY, char c){ | ||
lab[posX][posY] = c; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package backtracking; | ||
|
||
public class Main { | ||
|
||
public Main() { | ||
} | ||
public static void main(String[] args) { | ||
Maus maus = new Maus(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package backtracking; | ||
|
||
public class Maus { | ||
public Labyrinth lab = new Labyrinth(); | ||
|
||
public Maus() { | ||
lab.ausgeben(); | ||
sucheKaese(1, 0); | ||
} | ||
|
||
public void sucheKaese(int posX, int posY) { | ||
|
||
if (lab.gefunden(posX, posY)) { | ||
System.out.println("Käse gefunden"); | ||
lab.ausgeben(); | ||
} | ||
else { | ||
lab.setzteMaus(posX, posY, 'M'); | ||
if (lab.rechtsFrei(posX, posY)) { | ||
sucheKaese(++posX, posY); | ||
} | ||
if (lab.linksFrei(posX, posY)) { | ||
sucheKaese(--posX, posY); | ||
} | ||
if (lab.obenFrei(posX, posY)) { | ||
sucheKaese(posX, --posY); | ||
} | ||
if (lab.untenFrei(posX, posY)) { | ||
sucheKaese(posX, ++posY); | ||
} | ||
} | ||
lab.setzteMaus(posX, posY, ' '); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
subprojects { | ||
repositories { | ||
maven { | ||
url "https://nexus.in.fiduciagad.de/repository/maven2-internet-proxy/" | ||
credentials { | ||
username "xgtconrb" | ||
password "BCCeWDUWjgcQc6Kcmpa2kwBF252xpQxwKGgUnKmbD3v5FJmaCjB8NBq9VPn9kVxx" | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Tue Sep 10 14:56:27 CEST 2019 | ||
distributionUrl=https\://nexus.fiducia.de/nexus/content/repositories/thirdparty/org/gradle/gradle-all/5.5/gradle-all-5.5.zip | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
Oops, something went wrong.