Beispiel #1
0
    def __init__(self, source: IO = None):
        # Default to J2SE_7
        self._version = ClassVersion(0x32, 0)
        self._constants = ConstantPool()
        self.access_flags = Flags(
            '>H', {
                'acc_public': 0x0001,
                'acc_final': 0x0010,
                'acc_super': 0x0020,
                'acc_interface': 0x0200,
                'acc_abstract': 0x0400,
                'acc_synthetic': 0x1000,
                'acc_annotation': 0x2000,
                'acc_enum': 0x4000
            })
        self._this = 0
        self._super = 0
        self._interfaces = []
        self.fields = FieldTable(self)
        self.methods = MethodTable(self)
        self.attributes = AttributeTable(self)
        #: The ClassLoader bound to this ClassFile, if any.
        self.classloader = None

        if source:
            self._from_io(source)
Beispiel #2
0
Datei: code.py Projekt: nexB/Lawu
 def __init__(self, table, name_index=None):
     super(CodeAttribute, self).__init__(
         table, name_index or table.cf.constants.create_utf8('Code').index)
     self.max_stack = 0
     self.max_locals = 0
     self.exception_table = []
     self.attributes = AttributeTable(table.cf, parent=self)
     self._code = ''
Beispiel #3
0
 def __init__(self, cf):
     self._cf = cf
     self.access_flags = Flags(
         '>H', {
             'acc_public': 0x0001,
             'acc_private': 0x0002,
             'acc_protected': 0x0004,
             'acc_static': 0x0008,
             'acc_final': 0x0010,
             'acc_volatile': 0x0040,
             'acc_transient': 0x0080,
             'acc_synthetic': 0x1000,
             'acc_enum': 0x4000
         })
     self._name_index = 0
     self._descriptor_index = 0
     self.attributes = AttributeTable(cf)
Beispiel #4
0
 def __init__(self, cf):
     self._cf = cf
     self.access_flags = Flags('>H', {
         'acc_public': 0x0001,
         'acc_private': 0x0002,
         'acc_protected': 0x0004,
         'acc_static': 0x0008,
         'acc_final': 0x0010,
         'acc_synchronized': 0x0020,
         'acc_bridge': 0x0040,
         'acc_varargs': 0x0080,
         'acc_native': 0x0100,
         'acc_abstract': 0x0400,
         'acc_strict': 0x0800,
         'acc_synthetic': 0x1000
     })
     self._name_index = 0
     self._descriptor_index = 0
     self.attributes = AttributeTable(cf)
Beispiel #5
0
Datei: code.py Projekt: nexB/Lawu
    def unpack(self, info):
        """
        Read the CodeAttribute from the byte string `info`.

        .. note::

            Advanced usage only. You will typically never need to call this
            method as it will be called for you when loading a ClassFile.

        :param info: A byte string containing an unparsed CodeAttribute.
        """
        self.max_stack, self.max_locals, c_len = info.unpack('>HHI')
        self._code = info.read(c_len)

        # The exception table
        ex_table_len = info.u2()
        for _ in repeat(None, ex_table_len):
            self.exception_table.append(CodeException(*info.unpack('>HHHH')))
        self.attributes = AttributeTable(self.cf, parent=self)
        self.attributes.unpack(info)