Smart Agents Dialog Box

This dialog box is accessed from the SmartAgents button in the Conversion Settings dialog box.

Smart Agents work only in JAVA conversion mode.

The Smart Agents make the converted file easier to read and closer to the original java source code. All Smart Agents should normally be set (this is the default).

If no Smart Agents are set, the conversion is syntactically correct and the output produced is closer to what is actually compiled for the Java Virtual Machine but it is more difficult to read.

Unnecessary Fully Qualified Names

The Java Virtual Machine uses fully qualified names. This is syntactically correct but Java allows unqualified names to be understood in source code:

Redundant 'return' Statements

The Java Virtual Machine requires each method to be terminated with a  return  instruction. While this is syntactically correct and does no harm, it is unnecessary in the source code because a  return;  is understood in the closing brace of the method. For example:

  void method() {
    ...
    return;
  }

is replaced by:

  void method() {
    ...
  }

Note that this Smart Agent does not affect methods that return a parameter. For example, there is no change to:

  int method() {
    ...
    return x;
  }

Unreferenced Local Variables

Some source code expressions within a method can cause a Java compiler to generate temporary local variables. While this process happens transparently, it nevertheless generates a real local variable in the class file. When converting to a Java source file, ClassCracker generates a default name in the variable declaration section of the method. The names generated by ClassCracker are of the form  locVar_#  where # is a consecutive number.

If these local variables are not expressly referenced within the method's code (which is usually the case) they can be removed from the declaration section. This Smart Agent removes such unreferenced local variables.

Declared 'Exception' Local Variables

Local variables belonging to the  Exception  class and its subclasses are often declared as a formal parameter in a  catch  statement. Alternatively, they can be declared together with the other local variables in the variable declaration section of the method.

This Smart Agent removes 'Exception' local variables from the variable declaration section of the method if they are already declared in a  catch  statement.

String Concatenation Method

The Java Virtual Machine is not aware of the  +  string concatenation operator. When a Java source file is compiled, this operator is first converted by the compiler to the  String.concat()  method and this is what is stored in the class file.

When ClassCracker decompiles the class file, the  String.concat()  method is returned. This Smart Agent replaces the  String.concat()  method with the  +  string concatenation operator.

This Smart Agent also simplifies string expressions containing the  StringBuffer  class which is sometimes generated by Java compilers.


Copyright © 2002 Mayon Enterprises Pty Ltd.