This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
But shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?
Welcome =) About the new questions:
>shouldn't this code fail at compile time? I have seen this kind of code getting compiled without any error. So what exactly would be the behavior. Will jvm simply ignore this at runtime?
The code will not fail in compile time due there isn't this kind of evaluation during this process from the Javac process perspective. Maybe a good IDE may point this as a warning to make you aware that you might not get the desired behavior. The problem about the compile time, the Javac will just see if you have the correct syntax (liek keywords and their order to put in a nutshell) and the dependencies (to make the references inside the .class file). The real "magic" happens in the application server, which the container thread analyze your deployment package and create some proxies and/or aspects to provide the services described in Java EE specification. So, the container may also display some message of warn/error, depeding if it obligation d(if described in Java EE specification or not).