-
Bug
-
Resolution: Unresolved
-
P3
-
24, 25, 26
-
In Review
The meaning of the assertion
Throws: IllegalArgumentException if an existing catch block catches all exceptions is ambiguous. The following piece of code can be interpreted as indefinite:
(Consumer<CodeBuilder.CatchBuilder>) catchBuilder -> {
catchBuilder.catchingAll(tb -> {
tb.astore(1);
tb.iconst_0();
tb.ireturn();
});
catchBuilder.catchingAll(tb -> {
tb.astore(1);
tb.iconst_1();
tb.ireturn();
});
};
Presumably, it should throw an IllegalArgumentException. However, the expected exception is not thrown. Also, no cases were found that could propagate this exception, so the assertion seems superfluous in the specification.
The following sequence also looks like a candidate to throw an IllegalArgumentException:
(Consumer<CodeBuilder.CatchBuilder>) catchBuilder -> {
catchBuilder.catchingAll(
tb -> {
tb.astore(1);
tb.iconst_0();
tb.ireturn();
});
catchBuilder.catching( classDescOf(Exception.class),
tb -> {
tb.astore(1);
tb.iconst_1();
tb.ireturn();
});
}
--------------------------
CatchBuilder is intended to construct exception handlers together with code blocks in a CodeBuilder. Currently, it has arbitrary IAE throwing behavior when it detects duplicate blocks catching the same exception, which means the latter blocks are ignored by JVMS. However, such ignorance of duplicate blocks also happen with supertype entries occuring before subtype ones. So such checks are costly and not sound, and it's better for us to just remove them completely.
Throws: IllegalArgumentException if an existing catch block catches all exceptions is ambiguous. The following piece of code can be interpreted as indefinite:
(Consumer<CodeBuilder.CatchBuilder>) catchBuilder -> {
catchBuilder.catchingAll(tb -> {
tb.astore(1);
tb.iconst_0();
tb.ireturn();
});
catchBuilder.catchingAll(tb -> {
tb.astore(1);
tb.iconst_1();
tb.ireturn();
});
};
Presumably, it should throw an IllegalArgumentException. However, the expected exception is not thrown. Also, no cases were found that could propagate this exception, so the assertion seems superfluous in the specification.
The following sequence also looks like a candidate to throw an IllegalArgumentException:
(Consumer<CodeBuilder.CatchBuilder>) catchBuilder -> {
catchBuilder.catchingAll(
tb -> {
tb.astore(1);
tb.iconst_0();
tb.ireturn();
});
catchBuilder.catching( classDescOf(Exception.class),
tb -> {
tb.astore(1);
tb.iconst_1();
tb.ireturn();
});
}
--------------------------
CatchBuilder is intended to construct exception handlers together with code blocks in a CodeBuilder. Currently, it has arbitrary IAE throwing behavior when it detects duplicate blocks catching the same exception, which means the latter blocks are ignored by JVMS. However, such ignorance of duplicate blocks also happen with supertype entries occuring before subtype ones. So such checks are costly and not sound, and it's better for us to just remove them completely.
- csr for
-
JDK-8364302 java.lang.classfile.CodeBuilder.CatchBuilder should not throw IllegalArgumentException for representable exception handlers
-
- Draft
-
- links to
-
Review(master) openjdk/jdk/26372