|
21 | 21 | import static net.bytebuddy.jar.asm.Opcodes.ACC_MANDATED; |
22 | 22 | import static net.bytebuddy.jar.asm.Opcodes.ACC_MODULE; |
23 | 23 | import static net.bytebuddy.jar.asm.Opcodes.ACC_OPEN; |
| 24 | +import static net.bytebuddy.jar.asm.Opcodes.ACC_STATIC_PHASE; |
24 | 25 | import static net.bytebuddy.jar.asm.Opcodes.ACC_TRANSITIVE; |
25 | 26 | import static net.bytebuddy.jar.asm.Opcodes.ASM9; |
26 | 27 |
|
@@ -491,7 +492,13 @@ public void visit(ModuleRequiresDirective n, Void arg) { |
491 | 492 | // name. Therefore, the 'processed.' prefix added by bazel must be removed to get the name. |
492 | 493 | name = name.substring(10); |
493 | 494 | } |
494 | | - byteBuddyVisitor.visitRequire(name, getByteBuddyModifier(n.getModifiers()), null); |
| 495 | + int modifiers = getByteBuddyModifier(n.getModifiers()); |
| 496 | + if (!name.startsWith("org.seleniumhq.selenium.") && !name.startsWith("java.")) { |
| 497 | + // Some people like to exclude jars from the classpath. To allow this we need to make these modules static, |
| 498 | + // otherwise a 'module not found' error while compiling their code would be the consequence. |
| 499 | + modifiers |= ACC_STATIC_PHASE; |
| 500 | + } |
| 501 | + byteBuddyVisitor.visitRequire(name, modifiers, null); |
495 | 502 | } |
496 | 503 |
|
497 | 504 | @Override |
@@ -530,8 +537,11 @@ private int getByteBuddyModifier(NodeList<Modifier> modifiers) { |
530 | 537 | return modifiers.stream() |
531 | 538 | .mapToInt( |
532 | 539 | mod -> { |
533 | | - if (mod.getKeyword() == Modifier.Keyword.TRANSITIVE) { |
534 | | - return ACC_TRANSITIVE; |
| 540 | + switch (mod.getKeyword()) { |
| 541 | + case STATIC: |
| 542 | + return ACC_STATIC_PHASE; |
| 543 | + case TRANSITIVE: |
| 544 | + return ACC_TRANSITIVE; |
535 | 545 | } |
536 | 546 | throw new RuntimeException("Unknown modifier: " + mod); |
537 | 547 | }) |
|
0 commit comments