Java Programming Pitfalls
When debugging Java code, watch out for the following tricky spots:
- You can't define multiple constructors or overloaded methods for the classes WebApplication, WebSession, Component, or any other class that originates as an Objective-C class. For example, the following code causes your application to crash:
public class MyComponent extends Component { public void myMethod() { .... }
//WRONG! Overloaded method causes runtime error. public void myMethod(int anInt) { ... } }
// From a component's Java file. ((Session)session()).verify();
By definition, session returns a WebSession object. Because WebSession does not define a method named verify, your code won't compile unless you cast the return value of session to your WebSession subclass.