File tree Expand file tree Collapse file tree
liquidjava-example/src/main/java/testSuite/classes/inherited_constant_correct
liquidjava-verifier/src/main/java/liquidjava/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package testSuite .classes .inherited_constant_correct ;
2+
3+ import liquidjava .specification .ExternalRefinementsFor ;
4+ import liquidjava .specification .Refinement ;
5+ import liquidjava .specification .StateRefinement ;
6+ import liquidjava .specification .StateSet ;
7+
8+ @ StateSet ({"start" , "explicit" })
9+ @ ExternalRefinementsFor ("javax.imageio.ImageWriteParam" )
10+ public interface ImageWriteParamRefinements {
11+ @ StateRefinement (to = "mode == 2 ? explicit(this) : start(this)" )
12+ void setCompressionMode (@ Refinement ("_ >= 0 && _ <= 3" ) int mode );
13+
14+ @ StateRefinement (from = "explicit(this)" )
15+ void setCompressionQuality (@ Refinement ("_ >= 0.0 && _ <= 1.0" ) float quality );
16+ }
Original file line number Diff line number Diff line change 1+ package testSuite .classes .inherited_constant_correct ;
2+
3+ import javax .imageio .ImageIO ;
4+ import javax .imageio .ImageWriteParam ;
5+ import javax .imageio .plugins .jpeg .JPEGImageWriteParam ;
6+
7+ public class SimpleTest {
8+
9+ public static void main (String [] args ) {
10+ ImageWriteParam param = ImageIO .getImageWritersByFormatName ("jpeg" ).next ().getDefaultWriteParam ();
11+ param .setCompressionMode (JPEGImageWriteParam .MODE_EXPLICIT );
12+ param .setCompressionQuality (0.5f );
13+ }
14+ }
Original file line number Diff line number Diff line change @@ -30,8 +30,8 @@ private StaticConstants() {
3030 *
3131 * <p>
3232 * Tries the source AST first ({@link CtLiteral} initializer in Spoon's model), then reflection via
33- * {@link CtFieldReference#getActualField( )} + {@link #readStaticFinal}. Returns {@code null} if the field isn't
34- * static-final, has a non-literal initializer, or any lookup step fails.
33+ * {@link Class#getField(String )} + {@link #readStaticFinal} so inherited public constants are included. Returns
34+ * {@code null} if the field isn't static-final, has a non-literal initializer, or any lookup step fails.
3535 *
3636 * @see #resolve(String, String, CtElement) sibling for refinement-string {@code Type.CONST} references
3737 */
@@ -43,8 +43,8 @@ public static Object resolve(CtFieldReference<?> ref) {
4343 if (v != null )
4444 return v ;
4545 try {
46- return ref .getActualField () instanceof Field jf ? readStaticFinal ( jf ) : null ;
47- } catch (RuntimeException | LinkageError ignored ) {
46+ return readStaticFinal ( ref .getDeclaringType (). getActualClass (). getField ( ref . getSimpleName ())) ;
47+ } catch (NoSuchFieldException | RuntimeException | LinkageError ignored ) {
4848 // Spoon throws SpoonClassNotFoundException; reflection can throw LinkageError. Fall through.
4949 return null ;
5050 }
You can’t perform that action at this time.
0 commit comments