|
28 | 28 |
|
29 | 29 | public class FitnessFunctionHelper { |
30 | 30 |
|
31 | | - public boolean isConstructor(BytecodeInstruction targetInstruction){ |
| 31 | + public boolean isConstructor(BytecodeInstruction targetInstruction) { |
32 | 32 | String methodName = targetInstruction.getMethodName(); |
33 | 33 | methodName = methodName.substring(0, methodName.indexOf('(')); |
34 | 34 | String classPath = targetInstruction.getClassName(); |
35 | 35 | int lastOccurrence = classPath.lastIndexOf("."); |
36 | | - if (lastOccurrence == -1){ |
| 36 | + if (lastOccurrence == -1) { |
37 | 37 | return false; |
38 | 38 | } |
39 | | - String className = classPath.substring(lastOccurrence+1); |
| 39 | + String className = classPath.substring(lastOccurrence + 1); |
40 | 40 | return className.equals(methodName); |
41 | | - |
42 | 41 | } |
43 | 42 |
|
44 | | - public TestFitnessFunction getSingleObjective(){ |
45 | | - return getFF(CrashProperties.fitnessFunctions[0],CrashProperties.getInstance().getStackTrace(0)); |
| 43 | + public TestFitnessFunction getSingleObjective() { |
| 44 | + return getFF(CrashProperties.fitnessFunctions[0], CrashProperties.getInstance().getStackTrace(0)); |
46 | 45 | } |
47 | | - public TestFitnessFunction[] getMultiObjectives(){ |
48 | | - if(CrashProperties.fitnessFunctions.length > 1){ |
| 46 | + |
| 47 | + public TestFitnessFunction[] getMultiObjectives() { |
| 48 | + if (CrashProperties.fitnessFunctions.length > 1) { |
49 | 49 | // Here, we have 1 crash and multiple fitness functions |
50 | | - TestFitnessFunction[] result = new TestFitnessFunction[CrashProperties.fitnessFunctions.length]; |
| 50 | + TestFitnessFunction[] result = new TestFitnessFunction[CrashProperties.fitnessFunctions.length]; |
51 | 51 | StackTrace singleCrash = CrashProperties.getInstance().getStackTrace(0); |
52 | | - for (int i = 0; i<CrashProperties.fitnessFunctions.length;i++){ |
53 | | - result[i] = getFF(CrashProperties.fitnessFunctions[i],singleCrash); |
| 52 | + for (int i = 0; i < CrashProperties.fitnessFunctions.length; i++) { |
| 53 | + result[i] = getFF(CrashProperties.fitnessFunctions[i], singleCrash); |
54 | 54 | } |
55 | 55 | return result; |
56 | | - }else if(CrashProperties.getInstance().getCrashesSize() > 1){ |
| 56 | + } else if (CrashProperties.getInstance().getCrashesSize() > 1) { |
57 | 57 | // Here, we have multiple crashes and 1 fitness function |
58 | 58 | int numberOfCrashes = CrashProperties.getInstance().getCrashesSize(); |
59 | | - TestFitnessFunction[] result = new TestFitnessFunction[numberOfCrashes]; |
60 | | - for (int i = 0; i<numberOfCrashes;i++){ |
61 | | - result[i]= getFF(CrashProperties.fitnessFunctions[0],CrashProperties.getInstance().getStackTrace(i)); |
| 59 | + TestFitnessFunction[] result = new TestFitnessFunction[numberOfCrashes]; |
| 60 | + for (int i = 0; i < numberOfCrashes; i++) { |
| 61 | + result[i] = getFF(CrashProperties.fitnessFunctions[0], CrashProperties.getInstance().getStackTrace(i)); |
62 | 62 | } |
63 | 63 | return result; |
64 | | - }else{ |
65 | | - throw new IllegalStateException("Number of crashes and fitness functions are 1. Botsing cannot use a multi-objective algorithm"); |
| 64 | + } else { |
| 65 | + throw new IllegalStateException("Number of crashes and fitness functions are 1. Botsing cannot use a " + |
| 66 | + "multi-objective algorithm"); |
66 | 67 | } |
67 | 68 | } |
68 | 69 |
|
69 | | - private TestFitnessFunction getFF(CrashProperties.FitnessFunction givenFFName, StackTrace crash){ |
70 | | - switch (givenFFName){ |
| 70 | + private TestFitnessFunction getFF(CrashProperties.FitnessFunction givenFFName, StackTrace crash) { |
| 71 | + switch (givenFFName) { |
71 | 72 | case WeightedSum: |
72 | 73 | return new WeightedSum(crash); |
73 | 74 | case IntegrationSingleObjective: |
74 | 75 | return new IntegrationTestingFF(crash); |
75 | | - case IntegrationArrayIndex: |
76 | | - return new ITFFForArrayIndex(crash); |
| 76 | + case IntegrationIndexedAccess: |
| 77 | + return new ITFFForIndexedAccess(crash); |
77 | 78 | default: |
78 | 79 | return new WeightedSum(crash); |
79 | 80 | } |
80 | 81 | } |
81 | | - |
82 | | - |
83 | 82 | } |
0 commit comments