Class: JavaClass::ClassFile::AccessFlags
- Inherits:
-
Object
- Object
- JavaClass::ClassFile::AccessFlags
- Defined in:
- lib/javaclass/classfile/access_flags.rb
Overview
The access flags of a class or interface.
- Author
-
Peter Kofler
Constant Summary collapse
- ACC_PUBLIC =
Access flags as defined by JVM spec.
0x0001
- ACC_FINAL =
0x0010
- ACC_SUPER =
old invokespecial instruction semantics
0x0020
- ACC_INTERFACE =
0x0200
- ACC_ABSTRACT =
0x0400
- ACC_INNER =
TODO unknown access flag, find in spec
0x1000
- ACC_OTHER =
0xffff ^ ACC_PUBLIC ^ ACC_FINAL ^ ACC_SUPER ^ ACC_INTERFACE ^ ACC_ABSTRACT ^ ACC_INNER
Instance Method Summary collapse
- #abstract? ⇒ Boolean
- #final? ⇒ Boolean
-
#initialize(data, pos) ⇒ AccessFlags
constructor
A new instance of AccessFlags.
- #interface? ⇒ Boolean
-
#public? ⇒ Boolean
(also: #accessible?)
Return
true
if the class is public.
Constructor Details
#initialize(data, pos) ⇒ AccessFlags
Returns a new instance of AccessFlags.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/javaclass/classfile/access_flags.rb', line 19 def initialize(data, pos) @flags = data.u2(pos) raise "inconsistent flags #{@flags} (abstract and final)" if abstract? && final? if interface? && !abstract? # JDK 1.0 and 1.1 do have non abstract interfaces, fix it @flags = @flags | ACC_ABSTRACT end raise "inconsistent flags #{@flags} (interface not abstract)" if interface? && !abstract? raise "inconsistent flags #{@flags} (interface is final)" if interface? && final? raise "inconsistent flags #{@flags} (other value #{@flags & ACC_OTHER})" if (@flags & ACC_OTHER) != 0 end |
Instance Method Details
#abstract? ⇒ Boolean
41 42 43 |
# File 'lib/javaclass/classfile/access_flags.rb', line 41 def abstract? (@flags & ACC_ABSTRACT) != 0 end |
#final? ⇒ Boolean
37 38 39 |
# File 'lib/javaclass/classfile/access_flags.rb', line 37 def final? (@flags & ACC_FINAL) != 0 end |
#interface? ⇒ Boolean
45 46 47 |
# File 'lib/javaclass/classfile/access_flags.rb', line 45 def interface? (@flags & ACC_INTERFACE) != 0 end |
#public? ⇒ Boolean Also known as: accessible?
Return true
if the class is public.
32 33 34 |
# File 'lib/javaclass/classfile/access_flags.rb', line 32 def public? (@flags & ACC_PUBLIC) != 0 end |