-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge final release, with extra cache
Final release, with extra cache
- Loading branch information
Showing
62 changed files
with
1,299 additions
and
47 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
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
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,22 @@ | ||
#!/bin/bash | ||
|
||
TESTS_DIR=./tests_outputs/ | ||
|
||
# Compile as described in the project guide | ||
gradle compileJava build | ||
|
||
# Delete old out files | ||
rm tests_outputs/*my*out | ||
|
||
# Run tests with Gradle and save output to file | ||
for t in src/main/java/ist/meic/pa/GenericFunctionsExtended/examples/Test*.java; do | ||
test_name=$(basename $t .java) | ||
test_letter=$(echo $test_name | sed -r 's/Test//g') | ||
|
||
gradle clean runExtended -PrunArgs='ist.meic.pa.GenericFunctionsExtended.examples.'$test_name -q > $TESTS_DIR$test_letter.my_extended_out | ||
|
||
echo "Diff on "$test_name":" | ||
colordiff --strip-trailing-cr $TESTS_DIR$test_letter.my_extended_out $TESTS_DIR$test_letter.out | ||
|
||
done | ||
|
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
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
42 changes: 41 additions & 1 deletion
42
src/main/java/ist/meic/pa/GenericFunctions/injectors/utils/MethodUtils.java
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
11 changes: 11 additions & 0 deletions
11
src/main/java/ist/meic/pa/GenericFunctionsExtended/AfterMethod.java
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 @@ | ||
package ist.meic.pa.GenericFunctionsExtended; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface AfterMethod { | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/ist/meic/pa/GenericFunctionsExtended/BeforeMethod.java
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 @@ | ||
package ist.meic.pa.GenericFunctionsExtended; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface BeforeMethod { | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/ist/meic/pa/GenericFunctionsExtended/GenericFunction.java
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 @@ | ||
package ist.meic.pa.GenericFunctionsExtended; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface GenericFunction { | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/ist/meic/pa/GenericFunctionsExtended/WithGenericFunctions.java
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,42 @@ | ||
package ist.meic.pa.GenericFunctionsExtended; | ||
|
||
import ist.meic.pa.GenericFunctionsExtended.translator.GenericFunctionTranslator; | ||
import javassist.ClassPool; | ||
import javassist.Loader; | ||
import javassist.NotFoundException; | ||
import javassist.Translator; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.Arrays; | ||
|
||
public class WithGenericFunctions { | ||
public static void main(String[] args) { | ||
|
||
try { | ||
// Get our translator that will do our instrumentation | ||
Translator translator = new GenericFunctionTranslator(); | ||
|
||
// Get the current class pool and add our translator to it's loader | ||
ClassPool classPool = ClassPool.getDefault(); | ||
Loader classLoader = new Loader(); | ||
classLoader.addTranslator(classPool, translator); | ||
|
||
// Get the new parameters for the class we're about to hand over control to | ||
String[] parameters = Arrays.copyOfRange(args, 1, args.length); | ||
|
||
// Hand over control, providing the right arguments | ||
classLoader.run(args[0], parameters); | ||
|
||
} catch(ArrayIndexOutOfBoundsException e) { | ||
System.out.println("No main class was specified! Can't hand over control, ending."); | ||
System.exit(-1); | ||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | NotFoundException e) { | ||
// Can't really do anything about this, let's just end the program | ||
System.out.println("Reflection failed..."); | ||
System.exit(-1); | ||
} catch (Throwable throwable) { | ||
System.out.println("Failed to run main class! - " + throwable.getMessage()); | ||
System.exit(-1); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/ist/meic/pa/GenericFunctionsExtended/examples/TestA.java
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,15 @@ | ||
package ist.meic.pa.GenericFunctionsExtended.examples; | ||
|
||
|
||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Black; | ||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Blue; | ||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Color; | ||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Red; | ||
|
||
public class TestA { | ||
public static void main(String[] args) { | ||
Color[] colors = new Color[] { new Red(), new Blue(), new Black()}; | ||
for(Color c : colors) System.out.println(Color.mix(c)); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/ist/meic/pa/GenericFunctionsExtended/examples/TestB.java
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 @@ | ||
package ist.meic.pa.GenericFunctionsExtended.examples; | ||
|
||
|
||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Com; | ||
|
||
public class TestB { | ||
public static void main(String[] args) { | ||
Object[] objects = new Object[] { new Object(), "Foo", 123}; | ||
for(Object c : objects) System.out.println(Com.bine(c)); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/ist/meic/pa/GenericFunctionsExtended/examples/TestC.java
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,13 @@ | ||
package ist.meic.pa.GenericFunctionsExtended.examples; | ||
|
||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Black; | ||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Color; | ||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Red; | ||
|
||
public class TestC { | ||
public static void main(String[] args) { | ||
Object colors = new Object[] { new Red(), 2.9, new Black(), "Holla!"}; | ||
System.out.println(Color.mix(colors)); | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
src/main/java/ist/meic/pa/GenericFunctionsExtended/examples/TestD.java
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,14 @@ | ||
package ist.meic.pa.GenericFunctionsExtended.examples; | ||
|
||
|
||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Com; | ||
|
||
public class TestD { | ||
public static void main(String[] args) { | ||
Object objects = new Object[] { "Foo", new Integer[] {123, -12}}; | ||
System.out.println(Com.bine(objects)); | ||
|
||
Object numbers = new Object[] { 123, new Integer[] {456 , 21}}; | ||
System.out.println(Com.bine(numbers)); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/ist/meic/pa/GenericFunctionsExtended/examples/TestE.java
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 ist.meic.pa.GenericFunctionsExtended.examples; | ||
|
||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Identify; | ||
|
||
public class TestE { | ||
public static void main(String[] args) { | ||
Object objects = new Object[] { 123, "Foo", 1.2}; | ||
System.out.println(Identify.it(objects)); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/ist/meic/pa/GenericFunctionsExtended/examples/TestF.java
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,13 @@ | ||
package ist.meic.pa.GenericFunctionsExtended.examples; | ||
|
||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.Bug; | ||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.C1; | ||
import ist.meic.pa.GenericFunctionsExtended.examples.domain.C2; | ||
|
||
public class TestF { | ||
public static void main(String[] args) { | ||
Object c1 = new C1(), c2 = new C2(); | ||
Bug.bug(c1); | ||
Bug.bug(c2); | ||
} | ||
} |
Oops, something went wrong.