fixes #7 ModuleServer threw the Exception while fetching the constructors of the module class. The ordering of constructors in the returned array has for some reason changed between Java 6 and 7. New code checks for a constructor with the exact number of required parameters.

Also fixes 2 UTF-8 incompatible files.
This commit is contained in:
Fabian Becker 2012-04-12 14:47:00 +00:00
parent a9c0f3a4cf
commit 7d3d20c4b7
3 changed files with 9 additions and 6 deletions

View File

@ -163,22 +163,25 @@ public class ModuleServer {
selectedModuleName); selectedModuleName);
Constructor<?>[] constructorArr = module.getConstructors(); Constructor<?>[] constructorArr = module.getConstructors();
// create a module instance // create a module instance
int constrIndex=0;
if ((goParams==null && noGuiLogFile==null) || !module.equals(GOModuleAdapter.class)) { if ((goParams==null && noGuiLogFile==null) || !module.equals(GOModuleAdapter.class)) {
if (goParams!=null) System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)"); if (goParams!=null) System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)");
if (noGuiLogFile!=null) System.err.println("Cant deactivate GUI - no matching constructor found for " + adapterName + " (ModuleServer)"); if (noGuiLogFile!=null) System.err.println("Cant deactivate GUI - no matching constructor found for " + adapterName + " (ModuleServer)");
Object[] Para = new Object[2]; Object[] Para = new Object[2];
Class<?> paramTypes[] = (constructorArr[0]).getParameterTypes(); while ((constructorArr[constrIndex].getParameterTypes().length!=2) && (constrIndex < constructorArr.length)) {
constrIndex++;
}
Class<?> paramTypes[] = (constructorArr[constrIndex]).getParameterTypes();
Para[0] = paramTypes[0].cast(adapterName); Para[0] = paramTypes[0].cast(adapterName);
Para[1] = paramTypes[1].cast(Client); Para[1] = paramTypes[1].cast(Client);
m_ModuleAdapter = (ModuleAdapter) constructorArr[0].newInstance(Para); m_ModuleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(Para);
} else { } else {
Object[] Para = new Object[4]; Object[] Para = new Object[4];
Para[0] = (String)adapterName; Para[0] = (String)adapterName;
Para[1] = (InterfaceGOParameters)goParams; Para[1] = (InterfaceGOParameters)goParams;
Para[2] = (String)noGuiLogFile; Para[2] = (String)noGuiLogFile;
Para[3] = (MainAdapterClient)Client; Para[3] = (MainAdapterClient)Client;
int constrIndex=0;
while ((constructorArr[constrIndex].getParameterTypes().length!=4) && (constrIndex < constructorArr.length)) { while ((constructorArr[constrIndex].getParameterTypes().length!=4) && (constrIndex < constructorArr.length)) {
constrIndex++; constrIndex++;
} }

View File

@ -63,7 +63,7 @@ public class ArchivingNSGAIISMeasure extends ArchivingNSGAII {
Arrays.sort(frontArray,new AbstractEAIndividualComparator(0)); Arrays.sort(frontArray,new AbstractEAIndividualComparator(0));
((AbstractEAIndividual)frontArray[0]).putData("HyperCube",Double.MAX_VALUE); //die beiden außen bekommen maximal wert als smeasure ((AbstractEAIndividual)frontArray[0]).putData("HyperCube",Double.MAX_VALUE); //die beiden aussen bekommen maximal wert als smeasure
((AbstractEAIndividual)frontArray[frontArray.length-1]).putData("HyperCube",Double.MAX_VALUE); ((AbstractEAIndividual)frontArray[frontArray.length-1]).putData("HyperCube",Double.MAX_VALUE);
v[0]=Double.MAX_VALUE; v[0]=Double.MAX_VALUE;
v[frontArray.length-1]=Double.MAX_VALUE; v[frontArray.length-1]=Double.MAX_VALUE;

View File

@ -139,7 +139,7 @@ public class RemoveSurplusIndividualsSMetric implements InterfaceRemoveSurplusIn
} }
result[global[ sort[ 0 ] ]]=Double.MAX_VALUE; //die beiden außen bekommen maximal wert als smeasure result[global[ sort[ 0 ] ]]=Double.MAX_VALUE; //die beiden aussen bekommen maximal wert als smeasure
result[global[ sort[ counter - 1 ] ]]=Double.MAX_VALUE; result[global[ sort[ counter - 1 ] ]]=Double.MAX_VALUE;
for (int e = 1; e < counter - 1; e++) for (int e = 1; e < counter - 1; e++)