Reputation: 1531
I want to define and trigger some customized Java compilation errors in Eclipse. Basically I want that some system calls in some methods trigger a compilation error.
In this discussion an Annotaion based solution is proposed but it is not suitable in my case because I cannot predict when the copilation errors will happen. All I want is that when a developer makes a System Call for example a compilation error will be triggered.
Upvotes: 1
Views: 477
Reputation: 1
If you want to prevent developpers from using java.lang.System for example, a nice trick is to create a custom class java.lang.System in your projet, so every call to any methods of java.lang.System (the real one) will occure a compilation problem.
If you use maven, you can also create the class in a seperate maven project with scope provided to not be packaged with the real application.
Upvotes: 0
Reputation: 2146
Not exactly what you look for, but consider using a custom Checkstyle definition. Here is a sample from the checkstyle documentation that marks calls to System.out.println
as invalid:
<module name="Regexp">
<!-- . matches any character, so we need to escape it and use \. to match dots. -->
<property name="format" value="System\.out\.println"/>
<property name="illegalPattern" value="true"/>
</module>
Upvotes: 1
Reputation: 200148
You need to create your Builder
implementation and register it with the Java Project.
You could start here.
Upvotes: 0
Reputation: 32914
The only way to accomplish something like that would be to write a plug-in for Eclipse that analyzes code during builds. But the details of doing so is really out of the scope of a StackOverflow question.
Upvotes: 0