aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-03-02 01:32:28 +0100
committer zaaarf <zaaarf@proton.me>2023-03-02 01:32:28 +0100
commit25c4ca393f8d482f1bd7135c6e32100225a2c127 (patch)
treed0414c7ea477ee143b8a7bbab7bfacb6ca444340 /src/main/java/ftbsc
parent97c59cdc625b149dcbda3405d934879e76cef542 (diff)
fix: instantiate stub0.2.1
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r--src/main/java/ftbsc/lll/processor/LilleroProcessor.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/main/java/ftbsc/lll/processor/LilleroProcessor.java b/src/main/java/ftbsc/lll/processor/LilleroProcessor.java
index d4a6ae7..501200a 100644
--- a/src/main/java/ftbsc/lll/processor/LilleroProcessor.java
+++ b/src/main/java/ftbsc/lll/processor/LilleroProcessor.java
@@ -144,6 +144,10 @@ public class LilleroProcessor extends AbstractProcessor {
String injectorSimpleClassName = cl.getSimpleName().toString() + "Injector";
String injectorClassName = packageName + "." + injectorSimpleClassName;
+ MethodSpec stubOverride = MethodSpec.overriding(targetMethod)
+ .addStatement("throw new $T($S)", RuntimeException.class, "This is a stub and should not have been called")
+ .build();
+
MethodSpec inject = MethodSpec.methodBuilder("inject")
.addModifiers(Modifier.PUBLIC)
.returns(void.class)
@@ -159,13 +163,8 @@ public class LilleroProcessor extends AbstractProcessor {
.addStatement("super." + injectorMethod.getSimpleName() + "(clazz, main)", TypeName.get(cl.asType()))
.build();
- List<Modifier> injectorModifiers = new ArrayList<>();
- injectorModifiers.add(Modifier.PUBLIC);
- if(cl.getModifiers().contains(Modifier.ABSTRACT))
- injectorModifiers.add(Modifier.ABSTRACT); //so we dont actually have to instantiate the stubs
-
TypeSpec injectorClass = TypeSpec.classBuilder(injectorSimpleClassName)
- .addModifiers(injectorModifiers.toArray(new Modifier[0]))
+ .addModifiers(Modifier.PUBLIC)
.superclass(cl.asType())
.addSuperinterface(ClassName.get(IInjector.class))
.addMethod(buildStringReturnMethod("name", cl.getSimpleName().toString()))
@@ -174,6 +173,7 @@ public class LilleroProcessor extends AbstractProcessor {
.addMethod(buildStringReturnMethod("methodName", targetMethodSrgName))
.addMethod(buildStringReturnMethod("methodDesc", targetMethodDescriptor))
.addMethods(generateRequestedProxies(cl, mapper))
+ .addMethod(stubOverride)
.addMethod(inject)
.build();