Skip to content

JVMS-001: Interface Flags Combination Violation

Severity: JVM Specification Warning
JVM Spec Reference: Section 4.1, Table 4.1-B

According to the Java Virtual Machine Specification, the ACC_INTERFACE flag has strict requirements regarding its relationship with other access flags. Specifically:

If the ACC_INTERFACE flag is set, the ACC_ABSTRACT flag must also be set, and the ACC_FINAL, ACC_SUPER, ACC_ENUM, and ACC_MODULE flags must not be set.

Violation: Interface is not marked Abstract

Section titled “Violation: Interface is not marked Abstract”

In the JVM, all interfaces are implicitly abstract. Omitting this flag is a spec violation.

; Warning: Interface flag set but ACC_ABSTRACT is missing
.class interface public MyInterface

Interfaces cannot be final (because they must be implemented) or enum (which are specialized classes). Extrait de code

; Warning: Interface cannot be final
.class interface final public MyInterface
; Warning: Interface cannot be an enum
.class interface enum public MyInterface

To resolve this warning, ensure that any type flagged as an interface adheres to the following bitmask rules:

Always include ACC_ABSTRACT. Remove ACC_FINAL, ACC_SUPER, ACC_ENUM, and ACC_MODULE.

A typical public interface should only carry the 0x0601 mask (ACC_PUBLIC | ACC_INTERFACE | ACC_ABSTRACT). Extrait de code

; Correct Flag Usage
.class interface abstract public MyInterface