Permalink
Browse files

Updating compilers and paths in JNILibrary, plus some other formattin…

…g changes
  • Loading branch information...
philmcminn committed Jan 11, 2017
1 parent 8b8cfdd commit 72e62a555c27b5c0e9426509fb6bd29c500ce204
View
@@ -1 +1 @@
gcc -I"{JAVA_HOME}/include" -I"{JAVA_HOME}/include/linux" -I"{HANDLE_INCLUDE_PATH}" -o "{LIB_FILE}" -shared -fPIC "{HANDLE_SRC_FILE}" "{LIB_SRC_FILE}"
gcc -I"{JAVA_HOME}/include" -I"{JAVA_HOME}/include/linux" -I"{HANDLE_INCLUDE_PATH}" -I"{CASE_STUDY_PATH}" -o "{LIB_FILE}" -shared -fPIC "{HANDLE_SRC_FILE}" "{LIB_SRC_FILE}"
View
@@ -1,5 +1,3 @@
# Requires cc which can be downloaded with XCode
#cc -dynamiclib -o "{LIB_FILE}" -I"/System/Library/Frameworks/JavaVM.framework/Headers/" -I"{HANDLE_INCLUDE_PATH}" "{HANDLE_SRC_FILE}" "{LIB_SRC_FILE}" -framework JavaVM
gcc -dynamiclib -o "{LIB_FILE}" -I"{JAVA_HOME}/include/" -I"{JAVA_HOME}/include/darwin" -I"{HANDLE_INCLUDE_PATH}" -I"/Users/phil/Repos/IguanaTool/iguana/include/" "{HANDLE_SRC_FILE}" "{LIB_SRC_FILE}" -framework JavaVM
cc -dynamiclib -o "{LIB_FILE}" -I"{JAVA_HOME}/include/" -I"{JAVA_HOME}/include/darwin" -I"{HANDLE_INCLUDE_PATH}" -I"{CASE_STUDY_PATH}" "{HANDLE_SRC_FILE}" "{LIB_SRC_FILE}" -framework JavaVM
@@ -9,6 +9,6 @@
*/
public interface VariableIncluder {
public boolean[] performAnalysis(String aimDescription,
TestObject testObject);
boolean[] performAnalysis(String aimDescription,
TestObject testObject);
}
@@ -42,7 +42,7 @@ public int getNumEvaluations() {
}
public boolean success() {
return (bestSolution == null) ? false : bestSolution.isIdeal();
return bestSolution != null && bestSolution.isIdeal();
}
public Solution getBestSolution() {
@@ -12,6 +12,6 @@
*/
public interface MigrantSelector {
public Vector<Solution> select(SubPopulation p,
int numIndividuals);
Vector<Solution> select(SubPopulation p,
int numIndividuals);
}
@@ -9,5 +9,5 @@
*/
public interface MutationOperator {
public Solution mutate(Solution soln);
Solution mutate(Solution soln);
}
@@ -11,6 +11,6 @@
*/
public interface PopulationRankingMethod {
public void rank(Vector<SubPopulation> populations,
double[] fitness);
void rank(Vector<SubPopulation> populations,
double[] fitness);
}
@@ -11,6 +11,6 @@
*/
public interface RankingMethod {
public void rank(Vector<Solution> solutions,
double[] fitness);
void rank(Vector<Solution> solutions,
double[] fitness);
}
@@ -9,8 +9,8 @@
*/
public interface RecombinationOperator {
public void recombine(Solution parent1,
Solution parent2,
Solution child1,
Solution child2);
void recombine(Solution parent1,
Solution parent2,
Solution child1,
Solution child2);
}
@@ -11,6 +11,6 @@
*/
public interface ReinsertionMethod {
public Vector<Solution> reinsert(Vector<Solution> parents,
Vector<Solution> children);
Vector<Solution> reinsert(Vector<Solution> parents,
Vector<Solution> children);
}
@@ -11,7 +11,7 @@
*/
public interface SelectionMethod {
public Vector<Solution> select(Vector<Solution> pool,
int numParents);
Vector<Solution> select(Vector<Solution> pool,
int numParents);
}
@@ -14,15 +14,17 @@
import java.util.Map;
public class JNILibrary {
private static final String C_SRC_EXTENSION = ".c";
private static final String C_HEADER_EXTENSION = ".h";
private static final String HANDLE_INCLUDE_DIR = "include";
private static final String LIBRARY_DIR = "lib";
private static final String LIBRARY_SOURCE_DIR = LIBRARY_DIR + "/src";
private static final String LIBRARY_TEMPLATE_FILE = "lib.c";
private static final String LIBRARY_TEMPLATE_FILE = "lib" + C_SRC_EXTENSION;
private static final String PERFORM_CALL_DIR = "call";
private static final String PERFORM_CALL_TEMPLATE_FILE = "perform_call.c";
private static final String PERFORM_CALL_TEMPLATE_FILE = "perform_call" + C_SRC_EXTENSION;
private static final String TEST_OBJECT_HANDLE = "CTestObjectHandle";
private CaseStudy caseStudy;
private String testObjectName;
@@ -36,7 +38,7 @@ private File getHandleIncludePath() {
}
private File getHandleSourceFile() {
return new File(getHandleIncludePath() + "/" + TEST_OBJECT_HANDLE + ".c");
return new File(getHandleIncludePath() + "/" + TEST_OBJECT_HANDLE + C_SRC_EXTENSION);
}
public File getLibraryFile() {
@@ -49,7 +51,7 @@ private File getLibraryPath() {
}
private File getLibraryHeaderFile() {
return new File(getLibrarySourcePath() + "/" + testObjectName + ".h");
return new File(getLibrarySourcePath() + "/" + testObjectName + C_HEADER_EXTENSION);
}
private File getLibrarySourcePath() {
@@ -61,11 +63,11 @@ private File getPerformCallPath() {
}
private File getPerformCallSrcFile() {
return new File(getPerformCallPath() + "/" + testObjectName + ".c");
return new File(getPerformCallPath() + "/" + testObjectName + C_SRC_EXTENSION);
}
private File getLibrarySourceFile() {
return new File(getLibrarySourcePath() + "/" + testObjectName + ".c");
return new File(getLibrarySourcePath() + "/" + testObjectName + C_SRC_EXTENSION);
}
private File getPerformCallTemplateFile() {
@@ -113,7 +115,7 @@ public boolean makeLibrarySourceFile() throws IOException, ParseException {
SimpleIO.ensureDirectoryExists(getLibraryPath());
SimpleIO.ensureDirectoryExists(getLibrarySourcePath());
Map<String, String> searchAndReplace = new HashMap<String, String>();
Map<String, String> searchAndReplace = new HashMap<>();
searchAndReplace.put("{CASE_STUDY_NAME}", caseStudy.getName());
searchAndReplace.put("{INSTRUMENTED_CODE}", caseStudy.getInstrumentedCode());
searchAndReplace.put("{JNI_FUNCTION_NAME}", getJNIFunctionName());
@@ -133,7 +135,7 @@ public boolean makePerformCallFile() throws IOException {
File templateFile = getPerformCallTemplateFile();
SimpleIO.ensureDirectoryExists(getPerformCallPath());
Map<String, String> searchAndReplace = new HashMap<String, String>();
Map<String, String> searchAndReplace = new HashMap<>();
searchAndReplace.put("{TEST_OBJECT_NAME}", testObjectName);
TextFile.searchAndReplace(templateFile, targetFile, searchAndReplace);
@@ -151,13 +153,14 @@ public boolean compile() throws IOException, SystemCommandException {
SimpleIO.ensureDirectoryExists(getLibraryPath());
Map<String, String> locations = new HashMap<String, String>();
Map<String, String> locations = new HashMap<>();
// creating file objects and invoking getPath will convert paths so that they have OS-specific separators
// creating file objects and invoking getPath will convert paths so that they have OS-specific separators
locations.put("{CASE_STUDY_PATH}", caseStudy.getCaseStudyPath().toString());
locations.put("{JAVA_HOME}", Config.getInstance().getJavaPath().toString());
locations.put("{LIB_FILE}", libraryFile.getPath());
locations.put("{HANDLE_INCLUDE_PATH}", getHandleIncludePath().getPath());
locations.put("{HANDLE_SRC_FILE}", getHandleSourceFile().getPath());
locations.put("{LIB_FILE}", libraryFile.getPath());
locations.put("{LIB_PATH}", getLibraryPath().getPath());
locations.put("{LIB_SRC_FILE}", librarySourceFile.getPath());
@@ -11,29 +11,29 @@
/** This method is called after the node has been made the current
node. It indicates that child nodes can now be added to it. */
public void jjtOpen();
void jjtOpen();
/** This method is called after all the child nodes have been
added. */
public void jjtClose();
void jjtClose();
/** This pair of methods are used to inform the node of its
parent. */
public void jjtSetParent(Node n);
public Node jjtGetParent();
void jjtSetParent(Node n);
Node jjtGetParent();
/** This method tells the node to add its argument to the node's
list of children. */
public void jjtAddChild(Node n, int i);
void jjtAddChild(Node n, int i);
/** This method returns a child node. The children are numbered
from zero, left to right. */
public Node jjtGetChild(int i);
Node jjtGetChild(int i);
/** Return the number of children the node has. */
public int jjtGetNumChildren();
int jjtGetNumChildren();
/** Accept the visitor. **/
public void jjtAccept(CParserVisitor visitor);
void jjtAccept(CParserVisitor visitor);
}
/* JavaCC - OriginalChecksum=74141b3547c517f2ee2821902484d51b (do not edit this line) */
@@ -74,16 +74,16 @@ public void testSUS1() {
Vector<Solution> selected = s.select(pool, 4);
assertEquals("selected 1", 10,
((NumericalMaximizingObjectiveValue)selected.elementAt(0).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(0).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 2", 24,
((NumericalMaximizingObjectiveValue)selected.elementAt(1).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(1).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 3", 31,
((NumericalMaximizingObjectiveValue)selected.elementAt(2).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(2).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 4", 43,
((NumericalMaximizingObjectiveValue)selected.elementAt(3).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(3).getObjectiveValue().getNumericalValue(), 0.1);
}
public void testSUS2() {
@@ -122,22 +122,22 @@ public void testSUS2() {
Vector<Solution> selected = s.select(pool, 6);
assertEquals("selected 1", 24,
((NumericalMaximizingObjectiveValue)selected.elementAt(0).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(0).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 2", 24,
((NumericalMaximizingObjectiveValue)selected.elementAt(1).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(1).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 3", 43,
((NumericalMaximizingObjectiveValue)selected.elementAt(2).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(2).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 4", 43,
((NumericalMaximizingObjectiveValue)selected.elementAt(3).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(3).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 5", 43,
((NumericalMaximizingObjectiveValue)selected.elementAt(4).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(4).getObjectiveValue().getNumericalValue(), 0.1);
assertEquals("selected 6", 43,
((NumericalMaximizingObjectiveValue)selected.elementAt(5).getObjectiveValue()).getNumericalValue(), 0.1);
selected.elementAt(5).getObjectiveValue().getNumericalValue(), 0.1);
}
@@ -54,19 +54,19 @@ public void testTournament() {
RandomNumberGenerator r = new NonRandomNumberGenerator(integers);
TournamentSelection ts = new TournamentSelection(r, 2);
Solution ind = ts.doTournament(pool);
assertEquals("Tourny1 winner", 10, ((NumericalMaximizingObjectiveValue) ind.getObjectiveValue()).getNumericalValue(), 0.1);
assertEquals("Tourny1 winner", 10, ind.getObjectiveValue().getNumericalValue(), 0.1);
int[] integers2 = {1, 2};
r = new NonRandomNumberGenerator(integers2);
TournamentSelection ts2 = new TournamentSelection(r, 2);
ind = ts2.doTournament(pool);
assertEquals("Tourny2 winner", 15, ((NumericalMaximizingObjectiveValue) ind.getObjectiveValue()).getNumericalValue(), 0.1);
assertEquals("Tourny2 winner", 15, ind.getObjectiveValue().getNumericalValue(), 0.1);
int[] integers3 = {0, 1};
r = new NonRandomNumberGenerator(integers3);
TournamentSelection ts3 = new TournamentSelection(r, 2);
ind = ts3.doTournament(pool);
assertEquals("Tourny3 winner", 15, ((NumericalMaximizingObjectiveValue) ind.getObjectiveValue()).getNumericalValue(), 0.1);
assertEquals("Tourny3 winner", 15, ind.getObjectiveValue().getNumericalValue(), 0.1);
}
public static Test suite() {

0 comments on commit 72e62a5

Please sign in to comment.