Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.bcel.verifier.statics
Class Pass1Verifier

    java.lang.Object
      |
      +--org.apache.bcel.verifier.PassVerifier
            |
            +--org.apache.bcel.verifier.statics.Pass1Verifier

public final class Pass1Verifier
extends PassVerifier

This PassVerifier verifies a class file according to pass 1 as described in The Java Virtual Machine Specification, 2nd edition. More detailed information is to be found at the do_verify() method's documentation.

Version:
  $Id: Pass1Verifier.java,v 1.2 2002/06/13 09:32:50 enver Exp $
Author:
  Enver Haase
See Also:
  `do_verify()`

Constructor Summary
`Pass1Verifier(Verifier owner)` Should only be instantiated by a Verifier.

Method Summary
`VerificationResult` | `do_verify()` Pass-one verification basically means loading in a class file.
`java.lang.String[]` | `getMessages()` Currently this returns an empty array of String.

Methods inherited from class org.apache.bcel.verifier.PassVerifier
`addMessage, verify`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Pass1Verifier

    public Pass1Verifier(Verifier owner)

  Should only be instantiated by a Verifier.

See Also:
  `Verifier`

Method Detail

### do_verify

    public VerificationResult do_verify()

  Pass-one verification basically means loading in a class file. The Java Virtual Machine Specification is not too precise about what makes the difference between passes one and two. The answer is that only pass one is performed on a class file as long as its resolution is not requested; whereas pass two and pass three are performed during the resolution process. Only four constraints to be checked are explicitely stated by The Java Virtual Machine Specification, 2nd edition:
  - The first four bytes must contain the right magic number (0xCAFEBABE).
  - All recognized attributes must be of the proper length.
  - The class file must not be truncated or have extra bytes at the end.
  - The constant pool must not contain any superficially unrecognizable information.
  A more in-depth documentation of what pass one should do was written by Philip W. L. Fong:
  - the file should not be truncated.
  - the file should not have extra bytes at the end.
  - all variable-length structures should be well-formatted:
    - there should only be constant_pool_count-1 many entries in the constant pool.
    - all constant pool entries should have size the same as indicated by their type tag.
    - there are exactly interfaces_count many entries in the interfaces array of the class file.
    - there are exactly fields_count many entries in the fields array of the class file.
    - there are exactly methods_count many entries in the methods array of the class file.
    - there are exactly attributes_count many entries in the attributes array of the class file, fields, methods, and code attribute.
    - there should be exactly attribute_length many bytes in each attribute. Inconsistency between attribute_length and the actually size of the attribute content should be uncovered. For example, in an Exceptions attribute, the actual number of exceptions as required by the number_of_exceptions field might yeild an attribute size that doesn't match the attribute_length. Such an anomaly should be detected.
    - all attributes should have proper length. In particular, under certain context (e.g. while parsing method_info), recognizable attributes (e.g. "Code" attribute) should have correct format (e.g. attribute_length is 2).
  - Also, certain constant values are checked for validity:
    - The magic number should be 0xCAFEBABE.
    - The major and minor version numbers are valid.
    - All the constant pool type tags are recognizable.
    - All undocumented access flags are masked off before use. Strictly speaking, this is not really a check.
    - The field this_class should point to a string that represents a legal non-array class name, and this name should be the same as the class file being loaded.
    - the field super_class should point to a string that represents a legal non-array class name.
    - Because some of the above checks require cross referencing the constant pool entries, guards are set up to make sure that the referenced entries are of the right type and the indices are within the legal range (0 < index < constant_pool_count).
  - Extra checks done in pass 1:
    - the constant values of static fields should have the same type as the fields.
    - the number of words in a parameter list does not exceed 255 and locals_max.
    - the name and signature of fields and methods are verified to be of legal format.
  (From the Paper The Mysterious Pass One, first draft, September 2, 1997.) However, most of this is done by parsing a class file or generating a class file into BCEL's internal data structure. Therefore, all that is really done here is look up the class file from BCEL's repository. This is also motivated by the fact that some omitted things (like the check for extra bytes at the end of the class file) are handy when actually using BCEL to repair a class file (otherwise you would not be able to load it into BCEL).

  Specified by:
    `do_verify` in class `PassVerifier`
  See Also:
    `Repository`

### getMessages

    public java.lang.String[] getMessages()

  Currently this returns an empty array of String. One could parse the error messages of BCEL (written to java.lang.System.err) when loading a class file such as detecting unknown attributes or trailing garbage at the end of a class file. However, Markus Dahm does not like the idea so this method is currently useless and therefore marked as TODO.

  Overrides:
    `getMessages` in class `PassVerifier`
  See Also:
    `PassVerifier.addMessage(String)`, `PassVerifier.do_verify()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.