Conversation
…h(). To test, create a sample annotation with Runtime retention policy. Annotate some class with this, then call environment.getTypesAnnotatedWith() in ModuleManager.java. However, this has one issue: ALL files in /out/production/engine are scanned (.json, .ogg, .png etc.) for annotations.
|
Hooray Jenkins reported success with all tests good! |
NicholasBatesNZ
left a comment
There was a problem hiding this comment.
I've tested this and my annotated classes do indeed appear in my list :)
Now just work on fixing that scanning issue and we should be good to go.
| import org.terasology.module.ModulePathScanner; | ||
| import org.terasology.module.ModuleRegistry; | ||
| import org.terasology.module.TableModuleRegistry; | ||
| import org.terasology.module.*; |
There was a problem hiding this comment.
For a couple of reasons, we don't like to use * imports, even if we do use all classes in the package. IntelliJ probably did this by default, so please revert back to the individual imports.
There was a problem hiding this comment.
Please refer to https://stackoverflow.com/questions/3587071/disable-intellij-starred-package-imports for tips on how to deal with this in the future.
|
Hooray Jenkins reported success with all tests good! |
1 similar comment
|
Hooray Jenkins reported success with all tests good! |
|
@manas96 Do you plan to handle the module code in this PR as well? |
|
@vampcat Yes I do. |
|
So I went to look at this again as I'd like to merge it even as-is to make it easier to work on the next stage (code modules etc) without having to start with a special branch. But after merging #256 this now crashes as you attempt to light your engine, at least with imperial small and big, due to an issue with the work sounds. With this branch (lacking #256) checked out everything is fine. Without this PR everything is fine. Both with both suddenly the work sounds can't be found or are otherwise unavailable. Interesting! |
|
@manas96 Hi, what's your progress on this? What's the overall status of this PR? |
|
Closing this as superseded by / completed by #381 ! |
Description
You can now use methods like
ModuleEnvironment'sgetTypesAnnotatedWith().Testing
I picked SolApplication:
At the end of
ModuleManager.java's constructor , put this line:Iterable<Class<?>> list = environment.getTypesAnnotatedWith(SampleAnnotation.class);Also put a breakpoint on this line.
Debug program, and examine value of
list. It will contain names of all classes annotated withSampleAnnotation.You will also get a bunch of Debug messages from
Reflections.java(See below)Outstanding Work
However, this has one issue: ALL files in /out/production/engine (.json, .ogg, .png etc.) are scanned for annotations. This causes a bunch of scan error messages in the console because
Reflections.javais trying to scan .json / .ogg / .png files for annotations.The scanner needs to scan only .class files.