Is there a way to define my own compile errors for Eclipse? I want to throw compile errors if certain objects are not instantiated.
To give you exactly what I want to do:
I have an Assets
class that holds null variables for all resources (images, sounds, etc.) and a LoadingScreen
class that initializes all of these resource objects. If I add a resource to the Assets
class but not to the LoadingScreen
class, it will mess up the whole application. I want to see an error in eclipse if the variables in the Assets
class are not also initialized in LoadingScreen
.
Is this possible?
The Quick Fix dialog can also be displayed by right clicking on the error item in the Problems view and selecting the Quick Fix menu item.
This means that your project isn't setup to include the JUnit libraries when it compiles; JUnit is not included in the Java runtime libraries (JRE System Library) so you have to add it to the build path.
I agree with LaurentG, I think you should solve this problem at Java level. For example, you could have a method which does at the end some final checks where you would check if any of your resources have a null pointer and throw a custom exception if you detect any.
if (resourceObject==null) {
throw new CustomException("Null pointer for resource object detected");
}
public class CustomException extends Exception {
public CustomException (String errorMsg) {
super(errorMsg);
}
}
However, there are too many unknowns to give a really precise and accurate answer. Some code would definitely help.
I think you can create a new plugin or modify jdt. The errors are detected when compiling using eclipse Batch compiler. You should take a look at this, and this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With