Skip to content

Java Classes

hydrophobis edited this page Mar 25, 2025 · 1 revision

Contents

ACC_PUBLIC:

Marks the class or member as public, making it accessible from any other class.

ACC_PRIVATE:

Marks the class or member as private, restricting access to the defining class only.

ACC_PROTECTED:

Marks the class or member as protected, making it accessible within its own package and by subclasses.

ACC_STATIC:

Marks the class or member as static, meaning it belongs to the class itself rather than an instance.

ACC_FINAL:

Marks the class or member as final, meaning it cannot be subclassed or overridden.

ACC_SUPER:

Indicates the class has a superclass. Used in conjunction with ACC_PUBLIC for classes that inherit from a parent class. Example:

ACC_PUBLIC | ACC_SUPER // Public class with a superclass
emit_u2("this class name")
emit_u2("super class name")

ACC_SYNCHRONIZED:

Used for methods to indicate that the method should be executed with synchronization, ensuring only one thread can access it at a time.

ACC_NATIVE:

Marks a method as native, meaning its implementation is in a language other than Java (typically C or C++) and will be linked at runtime.

ACC_INTERFACE:

Marks the class as an interface, meaning it cannot have instance methods but can contain abstract methods to be implemented by classes.

ACC_ABSTRACT:

Marks the class or method as abstract, indicating it cannot be instantiated (for classes) or must be implemented by subclasses (for methods).

ACC_STRICT:

Forces the JVM to follow the IEEE 754 floating-point standard strictly, ensuring precise floating-point calculations.

  • Magic number: 0xCAFEBABE to identify the file as a valid Java class file.
  • Version: Java 8 version with minor and major version specified.
  • Access flags: Marks the class's access level, ensuring proper permissions.
  • Class references: The current class and its superclass references.
  • Code Attribute Start: Defines the start of a code attribute, including the name, stack, and locals.
  • Code Attribute End: Completes the code block and adds exception handling or other attributes.

For detailed explanations on each component and their roles in Java class file structure, explore the individual sections.


Clone this wiki locally