Skip to content

Commit 615f176

Browse files
Refactor Package structure and remove reflection (#26)
* refactor: swtich from reflection to bytecode traversal for strategy * refactor: package cleanup
1 parent a13ee06 commit 615f176

13 files changed

Lines changed: 187 additions & 270 deletions

File tree

checker/src/main/java/io/github/eisop/runtimeframework/checker/nullness/NullnessRuntimeChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package io.github.eisop.runtimeframework.checker.nullness;
22

3-
import io.github.eisop.runtimeframework.core.EnforcementInstrumenter;
43
import io.github.eisop.runtimeframework.core.RuntimeChecker;
5-
import io.github.eisop.runtimeframework.core.RuntimeInstrumenter;
64
import io.github.eisop.runtimeframework.core.TypeSystemConfiguration;
75
import io.github.eisop.runtimeframework.core.ValidationKind;
86
import io.github.eisop.runtimeframework.filter.ClassInfo;
97
import io.github.eisop.runtimeframework.filter.Filter;
10-
import io.github.eisop.runtimeframework.policy.InstrumentationStrategy;
8+
import io.github.eisop.runtimeframework.instrumentation.EnforcementInstrumenter;
9+
import io.github.eisop.runtimeframework.instrumentation.RuntimeInstrumenter;
1110
import io.github.eisop.runtimeframework.resolution.BytecodeHierarchyResolver;
1211
import io.github.eisop.runtimeframework.resolution.HierarchyResolver;
12+
import io.github.eisop.runtimeframework.strategy.InstrumentationStrategy;
1313
import org.checkerframework.checker.nullness.qual.NonNull;
1414
import org.checkerframework.checker.nullness.qual.Nullable;
1515

framework/src/main/java/io/github/eisop/runtimeframework/agent/RuntimeTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.github.eisop.runtimeframework.agent;
22

33
import io.github.eisop.runtimeframework.core.RuntimeChecker;
4-
import io.github.eisop.runtimeframework.core.RuntimeInstrumenter;
54
import io.github.eisop.runtimeframework.filter.AnnotatedForFilter;
65
import io.github.eisop.runtimeframework.filter.ClassInfo;
76
import io.github.eisop.runtimeframework.filter.Filter;
7+
import io.github.eisop.runtimeframework.instrumentation.RuntimeInstrumenter;
88
import java.lang.classfile.ClassFile;
99
import java.lang.classfile.ClassModel;
1010
import java.lang.instrument.ClassFileTransformer;

framework/src/main/java/io/github/eisop/runtimeframework/core/RuntimeChecker.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import io.github.eisop.runtimeframework.filter.ClassInfo;
44
import io.github.eisop.runtimeframework.filter.Filter;
5-
import io.github.eisop.runtimeframework.policy.BoundaryStrategy;
6-
import io.github.eisop.runtimeframework.policy.InstrumentationStrategy;
7-
import io.github.eisop.runtimeframework.policy.StrictBoundaryStrategy;
5+
import io.github.eisop.runtimeframework.instrumentation.RuntimeInstrumenter;
6+
import io.github.eisop.runtimeframework.strategy.BoundaryStrategy;
7+
import io.github.eisop.runtimeframework.strategy.InstrumentationStrategy;
8+
import io.github.eisop.runtimeframework.strategy.StrictBoundaryStrategy;
89

910
/**
1011
* Represents a specific type system or check to be enforced (e.g., Nullness, Immutability). This

framework/src/main/java/io/github/eisop/runtimeframework/core/EnforcementInstrumenter.java renamed to framework/src/main/java/io/github/eisop/runtimeframework/instrumentation/EnforcementInstrumenter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package io.github.eisop.runtimeframework.core;
1+
package io.github.eisop.runtimeframework.instrumentation;
22

3+
import io.github.eisop.runtimeframework.core.CheckGenerator;
34
import io.github.eisop.runtimeframework.filter.ClassInfo;
45
import io.github.eisop.runtimeframework.filter.Filter;
5-
import io.github.eisop.runtimeframework.policy.InstrumentationStrategy;
66
import io.github.eisop.runtimeframework.resolution.HierarchyResolver;
77
import io.github.eisop.runtimeframework.resolution.ParentMethod;
8+
import io.github.eisop.runtimeframework.strategy.InstrumentationStrategy;
89
import java.lang.classfile.ClassBuilder;
910
import java.lang.classfile.ClassModel;
1011
import java.lang.classfile.CodeBuilder;

framework/src/main/java/io/github/eisop/runtimeframework/core/EnforcementTransform.java renamed to framework/src/main/java/io/github/eisop/runtimeframework/instrumentation/EnforcementTransform.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package io.github.eisop.runtimeframework.core;
1+
package io.github.eisop.runtimeframework.instrumentation;
22

3-
import io.github.eisop.runtimeframework.policy.InstrumentationStrategy;
3+
import io.github.eisop.runtimeframework.core.CheckGenerator;
4+
import io.github.eisop.runtimeframework.strategy.InstrumentationStrategy;
45
import java.lang.classfile.ClassModel;
56
import java.lang.classfile.CodeBuilder;
67
import java.lang.classfile.CodeElement;

framework/src/main/java/io/github/eisop/runtimeframework/core/RuntimeInstrumenter.java renamed to framework/src/main/java/io/github/eisop/runtimeframework/instrumentation/RuntimeInstrumenter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.eisop.runtimeframework.core;
1+
package io.github.eisop.runtimeframework.instrumentation;
22

33
import io.github.eisop.runtimeframework.filter.ClassInfo;
44
import io.github.eisop.runtimeframework.filter.Filter;

framework/src/main/java/io/github/eisop/runtimeframework/policy/StrictBoundaryStrategy.java

Lines changed: 0 additions & 143 deletions
This file was deleted.

framework/src/main/java/io/github/eisop/runtimeframework/util/AnnotatedFor.java renamed to framework/src/main/java/io/github/eisop/runtimeframework/qual/AnnotatedFor.java

File renamed without changes.

framework/src/main/java/io/github/eisop/runtimeframework/policy/BoundaryStrategy.java renamed to framework/src/main/java/io/github/eisop/runtimeframework/strategy/BoundaryStrategy.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.eisop.runtimeframework.policy;
1+
package io.github.eisop.runtimeframework.strategy;
22

33
import io.github.eisop.runtimeframework.core.CheckGenerator;
44
import io.github.eisop.runtimeframework.core.TypeSystemConfiguration;
@@ -248,7 +248,15 @@ public CheckGenerator getBridgeReturnCheck(ParentMethod parentMethod) {
248248
return null;
249249
}
250250

251-
private List<Annotation> getMethodParamAnnotations(MethodModel method, int paramIndex) {
251+
protected List<Annotation> getMethodAnnotations(MethodModel method) {
252+
List<Annotation> result = new ArrayList<>();
253+
method
254+
.findAttribute(Attributes.runtimeVisibleAnnotations())
255+
.ifPresent(attr -> result.addAll(attr.annotations()));
256+
return result;
257+
}
258+
259+
protected List<Annotation> getMethodParamAnnotations(MethodModel method, int paramIndex) {
252260
List<Annotation> result = new ArrayList<>();
253261
method
254262
.findAttribute(Attributes.runtimeVisibleParameterAnnotations())
@@ -269,7 +277,7 @@ private List<Annotation> getMethodParamAnnotations(MethodModel method, int param
269277
return result;
270278
}
271279

272-
private List<Annotation> getMethodReturnAnnotations(MethodModel method) {
280+
protected List<Annotation> getMethodReturnAnnotations(MethodModel method) {
273281
List<Annotation> result = new ArrayList<>();
274282
method
275283
.findAttribute(Attributes.runtimeVisibleAnnotations())
@@ -287,7 +295,7 @@ private List<Annotation> getMethodReturnAnnotations(MethodModel method) {
287295
return result;
288296
}
289297

290-
private List<Annotation> getFieldAnnotations(FieldModel field) {
298+
protected List<Annotation> getFieldAnnotations(FieldModel field) {
291299
List<Annotation> result = new ArrayList<>();
292300
field
293301
.findAttribute(Attributes.runtimeVisibleAnnotations())
@@ -305,7 +313,7 @@ private List<Annotation> getFieldAnnotations(FieldModel field) {
305313
return result;
306314
}
307315

308-
private List<Annotation> getLocalVariableAnnotations(MethodModel method, int slot) {
316+
protected List<Annotation> getLocalVariableAnnotations(MethodModel method, int slot) {
309317
List<Annotation> result = new ArrayList<>();
310318
method
311319
.code()

framework/src/main/java/io/github/eisop/runtimeframework/policy/InstrumentationStrategy.java renamed to framework/src/main/java/io/github/eisop/runtimeframework/strategy/InstrumentationStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package io.github.eisop.runtimeframework.policy;
1+
package io.github.eisop.runtimeframework.strategy;
22

33
import io.github.eisop.runtimeframework.core.CheckGenerator;
44
import io.github.eisop.runtimeframework.resolution.ParentMethod;

0 commit comments

Comments
 (0)