Repository navigation
Exported slice removes the return statement but retains a non-void method signature #69
Description
Description
The criterion is gammaWriter at line 34 (gammaWriter.data = stage4;). The slice retains private static int compute() but removes return result;. The input compiles; the exported slice fails with missing return statement.
Environment: JavaSlicer 1.3.0, JSysDG, OpenJDK 17; compilation with --release 11. Reproduced using the native CLI on 2026-10-02.
Reproducer
Save the following unchanged code as GeneratedProgram.java. Keep the line breaks: the criterion uses the line number.
public class GeneratedProgram {
private static final class Box {
int data;
Box(int data) {
this.data = data;
}
}
private static int compute() {
Box alpha = new Box(0);
Box beta = new Box(0);
Box gamma = new Box(0);
Box alphaWriter = alpha;
Box alphaReader = alpha;
Box betaWriter = beta;
Box betaReader = beta;
Box gammaWriter = gamma;
Box gammaReader = gamma;
int seed = 7;
alphaWriter.data = seed;
int readAlpha = alphaReader.data;
int stage1 = readAlpha + 1;
betaWriter.data = stage1;
int readBeta = betaReader.data;
int stage2 = readBeta * 2;
int stage3 = stage2 + 3;
int stage4 = stage3 - 1;
gammaWriter.data = stage4;
int readGamma = gammaReader.data;
int stage5 = readGamma + 5;
int result = stage5 * 2;
return result;
}
public static void main(String[] args) {
compute();
}
}Commands
Set JAR to sdg-cli-1.3.0-jar-with-dependencies.jar and run in the directory containing GeneratedProgram.java:
javac --release 11 -d input-classes GeneratedProgram.java
java -jar "$JAR" -t JSysDG -c 'GeneratedProgram.java#34:gammaWriter' -i . -o slice
javac --release 11 -d slice-classes slice/GeneratedProgram.javaThe first compilation and slicing succeed. The final compilation fails:
slice/GeneratedProgram.java:26: error: missing return statement
}
^
1 error
Actual exported slice (generated path comment abbreviated)
/*
This file was automatically generated as part of a slice with criterion
file: GeneratedProgram.java, line: 34, variable: gammaWriter
Original file: GeneratedProgram.java
*/
public class GeneratedProgram {
private static final class Box {
int data;
Box(int data) {
}
}
private static int compute() {
Box beta = new Box(0);
Box gamma = new Box(0);
Box betaReader = beta;
Box gammaWriter = gamma;
int readBeta = betaReader.data;
int stage2 = readBeta * 2;
int stage3 = stage2 + 3;
int stage4 = stage3 - 1;
gammaWriter.data = stage4;
}
public static void main(String[] args) {
compute();
}
}Expected result
The return type and retained body should remain consistent so that the exported method is compilable.
Possible cause
Return-statement pruning leaves a non-void method that can complete without a return. This is tracked locally as RC-JS-RETURN-SIGNATURE and is distinct from removing declarations required by retained references.
Activity