### Question:
CheckModuleAdapter extends ModuleVisitor { @Override public void visitRequire(final String module, final int access, final String version) { checkVisitEndNotCalled(); CheckClassAdapter.checkFullyQualifiedName(Opcodes.V9, module, "required module"); requiredModules.checkNameNotAlreadyDeclared(module); CheckClassAdapter.checkAccess( access, Opcodes.ACC_STATIC_PHASE | Opcodes.ACC_TRANSITIVE | Opcodes.ACC_SYNTHETIC | Opcodes.ACC_MANDATED); if (classVersion >= Opcodes.V10 && module.equals("java.base") && (access & (Opcodes.ACC_STATIC_PHASE | Opcodes.ACC_TRANSITIVE)) != 0) { throw new IllegalArgumentException( "Invalid access flags: " + access + " java.base can not be declared ACC_TRANSITIVE or ACC_STATIC_PHASE"); } super.visitRequire(module, access, version); } CheckModuleAdapter(final ModuleVisitor moduleVisitor, final boolean isOpen); protected  CheckModuleAdapter(
      final int api, final ModuleVisitor moduleVisitor, final boolean isOpen); @Override void visitMainClass(final String mainClass); @Override void visitPackage(final String packaze); @Override void visitRequire(final String module, final int access, final String version); @Override void visitExport(final String packaze, final int access, final String... modules); @Override void visitOpen(final String packaze, final int access, final String... modules); @Override void visitUse(final String service); @Override void visitProvide(final String service, final String... providers); @Override void visitEnd();  }### Answer:
@Test public void testVisitRequire_javaBaseTransitive() { CheckModuleAdapter checkModuleAdapter = new CheckModuleAdapter(null, false); checkModuleAdapter.classVersion = Opcodes.V10; Executable visitRequire = () -> checkModuleAdapter.visitRequire("java.base", Opcodes.ACC_TRANSITIVE, null); Exception exception = assertThrows(IllegalArgumentException.class, visitRequire); assertEquals( "Invalid access flags: 32 java.base can not be declared ACC_TRANSITIVE or ACC_STATIC_PHASE", exception.getMessage()); }
@Test public void testVisitRequire_javaBaseStaticPhase() { CheckModuleAdapter checkModuleAdapter = new CheckModuleAdapter(null, false); checkModuleAdapter.classVersion = Opcodes.V10; Executable visitRequire = () -> checkModuleAdapter.visitRequire("java.base", Opcodes.ACC_STATIC_PHASE, null); Exception exception = assertThrows(IllegalArgumentException.class, visitRequire); assertEquals( "Invalid access flags: 64 java.base can not be declared ACC_TRANSITIVE or ACC_STATIC_PHASE", exception.getMessage()); }
@Test public void testVisitRequire_javaBaseTransitiveAndStaticPhase() { CheckModuleAdapter checkModuleAdapter = new CheckModuleAdapter(null, false); checkModuleAdapter.classVersion = Opcodes.V10; Executable visitRequire = () -> checkModuleAdapter.visitRequire( "java.base", Opcodes.ACC_TRANSITIVE | Opcodes.ACC_STATIC_PHASE, null); Exception exception = assertThrows(IllegalArgumentException.class, visitRequire); assertEquals( "Invalid access flags: 96 java.base can not be declared ACC_TRANSITIVE or ACC_STATIC_PHASE", exception.getMessage()); }
@Test public void testVisitRequire_javaBaseTransitiveOrStaticPhaseAreIgnoredUnderJvms9() { CheckModuleAdapter checkModuleAdapter = new CheckModuleAdapter(null, false); checkModuleAdapter.classVersion = Opcodes.V9; Executable visitRequire = () -> checkModuleAdapter.visitRequire( "java.base", Opcodes.ACC_TRANSITIVE | Opcodes.ACC_STATIC_PHASE, null); assertDoesNotThrow(visitRequire); }