It is not allowed to drop o_ the end of a method body. A compile-time error occurs if the body of a method can complete normally. It is also a compiletime error if a statement cannot be executed because it is unreachable. Every Java compiler must carry out a conservative ow analysis to make sure that all statements are reachable. For this purpose two static predicates reachable and normal are computed at compile-time. The predicates have the following intended meanings:
The predicates are de_ned such that normal(_) implies reachable(_). Moreover, if a substatement is reachable, then the statement is reachable.
The reachability analysis is also used in in the proof that bytecode generated by the Java compiler of Part II is accepted by the bytecode veri_er. There, one has to show that execution cannot jump out of the code of a method.
At the root position of a method body the predicate reachable is determined by the following initial conditions: Let _block be the body of an instance method, constructor or class method or a static initializer. Then reachable(_) is True.
For the other positions in the block the predicates reachable and normal can then be computed in a top-down manner. Instead of explaining exactly how the functions are computed, in Table below we just state the equivalences the predicates have to satisfy. Constant boolean expressions are not treated the same way in all control structures. For example, in the while statement
the statement stm is not considered as reachable. In the if-then-else statement if (false) stm the statement stm, however, is considered as reachable. The reason for this di_erence is to allow programmers to use the if-then-else statement for conditional compilation".
For positions in expressions the predicate reachable is determined by the following de_nition.
De_nition (Reachable expression). An expression is reachable i_ the innermost statement containing it is reachable.
If an abruption occurs in a try block, the corresponding finally block is executed before the abruption moves upwards. If the finally block does not complete normally, the old abruption is discarded and cannot exit the try-finally statement.
De_nition(Abruption can exit statement). An abruption at position _ can exit stm, if for every substatement _(s finally _b) of stm such that _ is in s the predicate normal(_) is true.
We say that a break statement at position _ can exit stm, if an abruption at position _ can exit stm.
De_nition (Statement can throw exception). A statement stm can throw an exception E, if one of the following conditions is true:
At run-time the current position is always reachable. If a statement completes normally, then the statement is normal. The converse is not true. There are normal statements which can complete abruptly.
For example, in an if-then-else-statement one branch may be normal whereas the other branch completes abruptly.
JVM Related Interview Questions
|Java Script Interview Questions||Adv Java Interview Questions|
|Core Java Interview Questions||AJAX Interview Questions|
|Android Interview Questions||Java applet Interview Questions|
|Java 8 Interview Questions||JBOSS Interview Questions|
|Advanced jQuery Interview Questions||Apache Tomcat Interview Questions|
|Application Virtualization Interview Questions||Java 9 Interview Questions|
The Imperative Core Javai Of Java
The Procedural Extension Javac Of Javai
The Object-oriented Extension Javao Of Javac
The Exception-handling Extension Javae Of Javao
The Concurrent Extension Javat Of Javae
Java Is Type Safe
The Jvmi Submachine
The Procedural Extension Jvmc Of Jvmi
The Object-oriented Extension Jvmo Of Jvmc
The Exception-handling Extension Jvme Of Jvmo
Correctness Of The Compiler
The Defensive Virtual Machine
Bytecode Type Assignments
The Diligent Virtual Machine
The Dynamic Virtual Machine
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.