Fix "unchecked or unsafe operations" warning in javac (#1874)

Fix this printed warning during java compilation:

"Note: Some input files use unchecked or unsafe operations. Recompile with -Xlint:unchecked for details"

* Add `-Xlint:unchecked` as a javac flag
* Fix the various warnings
This commit is contained in:
Daniel Chao authored and GitHub committed 2026-09-24 09:28:49 -07:00
1 parent 119b1571bb
commit 43e132a383
6 files changed
+12 -10

No files matched your search

@@ -45,6 +45,7 @@ configurations {
tasks.withType<JavaCompile>().configureEach {
javaCompiler = buildInfo.javaCompiler
options.release = buildInfo.jvmTarget
options.compilerArgs.add("-Xlint:unchecked")
}
plugins.withType(IdeaPlugin::class).configureEach {
@@ -84,7 +84,7 @@ for ((key, value) in relocations) {
}
}
val nonRelocations = listOf("com/oracle/truffle/", "org/graalvm/", "org/jspecify")
val nonRelocations = listOf("com/oracle/truffle/", "org/graalvm/", "org/jspecify/")
tasks.shadowJar {
inputs.property("relocations", relocations)
@@ -312,6 +312,7 @@ public final class EvaluatorImpl implements Evaluator {
}
@Override
@SuppressWarnings("unchecked")
public <T> T evaluateOutputValueAs(ModuleSource moduleSource, PClassInfo<T> classInfo) {
return doEvaluate(
moduleSource,
@@ -322,10 +323,8 @@ public final class EvaluatorImpl implements Evaluator {
if (valueClassInfo.equals(classInfo)) {
if (value instanceof VmValue vmValue) {
vmValue.force(false);
//noinspection unchecked
return (T) vmValue.export();
}
//noinspection unchecked
return (T) value;
}
throw moduleOutputValueTypeMismatch(module, classInfo, value, output);
@@ -539,6 +539,7 @@ public final class SymbolTable {
@Nullable T apply(LexicalScope scope, int levelUp);
}
@SuppressWarnings("unchecked")
private @Nullable <R> R resolveLexical(ResolutionFunction<R> fun) {
var levelsUp = 0;
var shouldSkip = false;
@@ -560,7 +561,6 @@ public final class SymbolTable {
// are one level higher than the body itself.
var result = fun.apply(objectScope, levelsUp);
if (result instanceof Parameter parameter) {
//noinspection unchecked
return (R) new Parameter(parameter.slot(), parameter.levelsUp() - 1);
}
levelsUp++;
@@ -578,7 +578,6 @@ public final class SymbolTable {
var result = fun.apply(lex, levelsUp);
if (result != null) {
if (result instanceof ForGeneratorVariableOrLetBinding p && skippedObjectScope) {
//noinspection unchecked
return (R) new ForGeneratorVariableOrLetBinding(p.slot(), p.levelsUp(), true);
}
return result;
@@ -248,13 +248,17 @@ public final class Project {
.addResourceReader(ResourceReaders.pkg());
}
@SuppressWarnings("unchecked")
private static Map<String, PObject> getDependencies(PObject module) {
return (Map<String, PObject>) module.getProperty("dependencies");
}
private static DeclaredDependencies parseDependencies(
PObject module, URI projectFileUri, @Nullable PackageUri packageUri)
throws URISyntaxException {
var remoteDependencies = new HashMap<String, RemoteDependency>();
var localDependencies = new HashMap<String, DeclaredDependencies>();
//noinspection unchecked
var dependencies = (Map<String, PObject>) module.getProperty("dependencies");
var dependencies = getDependencies(module);
for (var entry : dependencies.entrySet()) {
var value = entry.getValue();
if (value.getClassInfo().equals(PClassInfo.Project)) {
@@ -332,8 +336,7 @@ public final class Project {
private static Map<String, Project> parseLocalProjectDependencies(PObject module)
throws URISyntaxException {
//noinspection unchecked
var dependencies = (Map<String, PObject>) module.getProperty("dependencies");
var dependencies = getDependencies(module);
var result = new HashMap<String, Project>();
for (var entry : dependencies.entrySet()) {
var value = entry.getValue();
@@ -356,6 +356,7 @@ final class Builder {
* Split a function call node to extract its identifier into the leading group. For example,
* {@code foo.bar(5)} becomes: leading gets {@code foo.bar}, rest gets {@code (5)}.
*/
@SuppressWarnings("unchecked")
private List<Node>[] splitFunctionCallNode(List<Node> nodes) {
assert !nodes.isEmpty();
var lastNode = nodes.get(nodes.size() - 1);
@@ -369,7 +370,6 @@ final class Builder {
var leading = new ArrayList<>(nodes.subList(0, nodes.size() - 1));
leading.addAll(lastNode.children.subList(0, argListIdx));
var trailing = lastNode.children.subList(argListIdx, lastNode.children.size());
//noinspection unchecked
return new List[] {leading, trailing};
}