The following java failed in javac (java 17.0.8)
public class Volatile {
final volatile boolean[] mask = new boolean[128];
}
Volatile.java:2: error: illegal combination of modifiers: final and volatile
final volatile boolean mask = new boolean[128];
^
However, the following scala file passed in scalac (Scala 3.4.0-RC1)
class Volatile:
@volatile final val mask: Array[Boolean] = Array.ofDim(128)
And decompiled as following codes:
/*
* Decompiled with CFR 0.152.
*/
public class Volatile {
private final volatile boolean[] mask = new boolean[128];
public final boolean[] mask() {
return this.mask;
}
}
Is this a bug in scalac, or, at least should be enhance in scalac ?