Switch statement in source results in type$1.class being generated?
Dávid Karnok
akarnokd at gmail.com
Fri Jul 12 08:30:26 UTC 2019
Hi.
As part of the outreach program, I'm testing the various JDK early access
builds with the library RxJava. Now that I can test JDK 13 and JDK 14 by
setting a version target in my IDE, I've come across a strange compiler
output not encountered with JDK 12 and prior versions. Note that RxJava's
source code uses Java 6 constructs only.
One of the rules for RxJava development is that there should be no
anonymous inner classes used as it makes analyzing stacktraces with all
those $12.class difficult. When the project is compiled, we check for the
existence of such type$x.class output and fail the build if found. This
worked well up until JDK 12, but now JDK 13 and JDK 14 early accesses
generate a couple of such $1.class files. As far as I can tell, they are
due to switch statements, for example:
https://github.com/akarnokd/RxJava3_BuildMatrix/blob/master/src/main/java/io/reactivex/Observable.java#L14379
switch (strategy) {
case DROP:
return f.onBackpressureDrop();
case LATEST:
return f.onBackpressureLatest();
case MISSING:
return f;
case ERROR:
return RxJavaPlugins.onAssembly(new
FlowableOnBackpressureError<T>(f));
default:
return f.onBackpressureBuffer();
}
Creates Observable$1.class:
javap Observable$1.class
Compiled from "Observable.java"
class io.reactivex.Observable$1 {
static final int[] $SwitchMap$io$reactivex$BackpressureStrategy;
static {};
}
Is this some kind of expected new artifact?
--
Best regards,
David Karnok
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20190712/188e4d5d/attachment.html>
More information about the compiler-dev
mailing list