summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
author zaaarf <zaaarf@proton.me>2023-06-11 15:55:22 +0200
committer zaaarf <zaaarf@proton.me>2023-06-11 15:55:22 +0200
commit3f730c69d3360ae7af030e9e5a4ebd065f8bb05a (patch)
treeabdf4e88ebda4e71c6e7c7325a34a0cd0af8e854 /src/main
parented70355a86f357b644bb7ecd7b90de5a5a6f6f76 (diff)
fix: don't call processingEnv before it's initialised
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/ftbsc/lll/processor/LilleroProcessor.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/main/java/ftbsc/lll/processor/LilleroProcessor.java b/src/main/java/ftbsc/lll/processor/LilleroProcessor.java
index b1d1f1e..0e170ee 100644
--- a/src/main/java/ftbsc/lll/processor/LilleroProcessor.java
+++ b/src/main/java/ftbsc/lll/processor/LilleroProcessor.java
@@ -48,7 +48,7 @@ public class LilleroProcessor extends AbstractProcessor {
/**
* An object representing the various options passed to the processor.
*/
- public final ProcessorOptions options = new ProcessorOptions(processingEnv);
+ private ProcessorOptions options = null;
/**
* Method overriding default implementation to manually pass supported options.
@@ -60,6 +60,16 @@ public class LilleroProcessor extends AbstractProcessor {
}
/**
+ * Returns the {@link ProcessorOptions} for this instance, creating the object if
+ * it hasn't been already.
+ * @return the {@link ProcessorOptions} for this instance
+ */
+ public ProcessorOptions getProcessorOptions() {
+ if(this.options == null) this.options = new ProcessorOptions(this.processingEnv);
+ return this.options;
+ }
+
+ /**
* Where the actual processing happens.
* It filters through whatever annotated class it's fed, and checks whether it contains
* the required information. It then generates injectors and a service provider for every
@@ -90,7 +100,7 @@ public class LilleroProcessor extends AbstractProcessor {
}
}
}
- if (!this.options.noServiceProvider && !this.injectors.isEmpty()) {
+ if (!this.getProcessorOptions().noServiceProvider && !this.injectors.isEmpty()) {
generateServiceProvider();
return true;
} else return false;
@@ -134,7 +144,7 @@ public class LilleroProcessor extends AbstractProcessor {
//find class information
Patch patchAnn = cl.getAnnotation(Patch.class);
ClassContainer targetClass = ClassContainer.from(
- patchAnn, Patch::value, patchAnn.innerName(), this.options
+ patchAnn, Patch::value, patchAnn.innerName(), this.getProcessorOptions()
);
//find package information
Element packageElement = cl.getEnclosingElement();
@@ -165,10 +175,10 @@ public class LilleroProcessor extends AbstractProcessor {
if(type == ProxyType.TYPE) {
//find and validate
ClassContainer clazz = ClassContainer.findOrFallback(
- ClassContainer.from(cl, this.options),
+ ClassContainer.from(cl, this.getProcessorOptions()),
patchAnn,
proxyVar.getAnnotation(Find.class),
- this.options
+ this.getProcessorOptions()
);
//types can be generated with a single instruction
constructorBuilder.addStatement(
@@ -184,7 +194,7 @@ public class LilleroProcessor extends AbstractProcessor {
null,
null,
constructorBuilder,
- this.options
+ this.getProcessorOptions()
);
}
@@ -243,7 +253,7 @@ public class LilleroProcessor extends AbstractProcessor {
matchedInjectors.add(injector);
toGenerate.put(
String.format("%sInjector%d", cl.getSimpleName(), iterationNumber),
- new InjectorInfo(injector, tg, targetAnn, this.options)
+ new InjectorInfo(injector, tg, targetAnn, this.getProcessorOptions())
);
iterationNumber++; //increment is only used by injectors
} else {
@@ -255,7 +265,7 @@ public class LilleroProcessor extends AbstractProcessor {
tg,
targetAnn,
constructorBuilder,
- this.options
+ this.getProcessorOptions()
);
}
}
@@ -280,9 +290,9 @@ public class LilleroProcessor extends AbstractProcessor {
.addMethod(constructorBuilder.build())
.addMethod(buildStringReturnMethod("name", injName))
.addMethod(buildStringReturnMethod("reason", toGenerate.get(injName).reason))
- .addMethod(buildStringReturnMethod("targetClass", this.options.obfuscateInjectorMetadata ? targetClass.fqnObf : targetClass.fqn))
- .addMethod(buildStringReturnMethod("methodName", this.options.obfuscateInjectorMetadata ? target.nameObf : target.name))
- .addMethod(buildStringReturnMethod("methodDesc", this.options.obfuscateInjectorMetadata ? target.descriptorObf : target.descriptor))
+ .addMethod(buildStringReturnMethod("targetClass", this.getProcessorOptions().obfuscateInjectorMetadata ? targetClass.fqnObf : targetClass.fqn))
+ .addMethod(buildStringReturnMethod("methodName", this.getProcessorOptions().obfuscateInjectorMetadata ? target.nameObf : target.name))
+ .addMethod(buildStringReturnMethod("methodDesc", this.getProcessorOptions().obfuscateInjectorMetadata ? target.descriptorObf : target.descriptor))
.addMethods(generateDummies(cl))
.addMethod(generateInjector(toGenerate.get(injName), this.processingEnv))
.build();