diff --git a/src/main/java/org/eclipse/yasson/FieldAccessStrategy.java b/src/main/java/org/eclipse/yasson/FieldAccessStrategy.java index 1ce711ff..68db366d 100644 --- a/src/main/java/org/eclipse/yasson/FieldAccessStrategy.java +++ b/src/main/java/org/eclipse/yasson/FieldAccessStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -28,6 +28,10 @@ * when SecurityManager is turned on.

*/ public class FieldAccessStrategy implements PropertyVisibilityStrategy { + + FieldAccessStrategy() { + } + @Override public boolean isVisible(Field field) { return true; diff --git a/src/main/java/org/eclipse/yasson/JsonBindingProvider.java b/src/main/java/org/eclipse/yasson/JsonBindingProvider.java index 3e4f4d40..f7aa7e23 100644 --- a/src/main/java/org/eclipse/yasson/JsonBindingProvider.java +++ b/src/main/java/org/eclipse/yasson/JsonBindingProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -22,6 +22,9 @@ */ public class JsonBindingProvider extends JsonbProvider { + public JsonBindingProvider() { + } + @Override public JsonbBuilder create() { return new JsonBindingBuilder(); diff --git a/src/main/java/org/eclipse/yasson/YassonConfig.java b/src/main/java/org/eclipse/yasson/YassonConfig.java index 9387eeab..d0a14535 100644 --- a/src/main/java/org/eclipse/yasson/YassonConfig.java +++ b/src/main/java/org/eclipse/yasson/YassonConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022 IBM and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023 IBM and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -21,6 +21,9 @@ * Custom properties for configuring Yasson outside of the specification {@link jakarta.json.bind.JsonbConfig} scope. */ public class YassonConfig extends JsonbConfig { + + public YassonConfig() { + } /** * @see #withFailOnUnknownProperties(boolean) diff --git a/src/test/java/org/eclipse/yasson/Assertions.java b/src/test/java/org/eclipse/yasson/Assertions.java index 8b23d7cb..aee564a7 100644 --- a/src/test/java/org/eclipse/yasson/Assertions.java +++ b/src/test/java/org/eclipse/yasson/Assertions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -20,6 +20,9 @@ import jakarta.json.bind.JsonbException; public class Assertions { + + private Assertions() { + } /** * Asserts that the given operation will fail with a JsonbException @@ -58,13 +61,13 @@ public static void shouldFail(Supplier operation, Class operation.get(); fail("The operation should have failed with a " + expectedType.getCanonicalName() + " but it succeeded."); } catch (Throwable t) { - String fullErrorMessage = ""; + StringBuilder fullErrorMessage = new StringBuilder(); for (Throwable current = t; current != null && current.getCause() != current; current = current.getCause()) { - fullErrorMessage += current.getClass().getCanonicalName() + ": "; - fullErrorMessage += current.getMessage() + "\n"; + fullErrorMessage.append(current.getClass().getCanonicalName()).append(": "); + fullErrorMessage.append(current.getMessage()).append("\n"); } if (expectedType.isAssignableFrom(t.getClass())) { - if (!checkExceptionMessage.apply(fullErrorMessage)) { + if (!checkExceptionMessage.apply(fullErrorMessage.toString())) { t.printStackTrace(); fail("Exception did not contain the proper content: " + fullErrorMessage); } diff --git a/src/test/java/org/eclipse/yasson/DefaultGetterInInterface.java b/src/test/java/org/eclipse/yasson/DefaultGetterInInterface.java index 9b5954ed..75dda715 100644 --- a/src/test/java/org/eclipse/yasson/DefaultGetterInInterface.java +++ b/src/test/java/org/eclipse/yasson/DefaultGetterInInterface.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -29,14 +29,19 @@ */ public class DefaultGetterInInterface { - public static interface Defaulted { + private DefaultGetterInInterface() { + } + + public interface Defaulted { - default public String getGetterA() { + default String getGetterA() { return "valueA"; } } public static class PojoWithDefault implements Defaulted { + protected PojoWithDefault() { + } } @Test @@ -46,13 +51,13 @@ public void testWithDefault() { assertEquals("{\"getterA\":\"valueA\"}", result); } - public static interface WithGetterI { + public interface WithGetterI { @JsonbProperty("withGetterI") String getGetterI(); } - public static interface WithDefaultGetterI extends WithGetterI { + public interface WithDefaultGetterI extends WithGetterI { @Override @JsonbProperty("default") @@ -61,7 +66,7 @@ default String getGetterI() { } } - public static interface OtherWithDefaultGetterI extends WithGetterI { + public interface OtherWithDefaultGetterI extends WithGetterI { @Override @JsonbProperty("otherDefault") @@ -72,6 +77,9 @@ default String getGetterI() { public static class Pojo implements WithGetterI { + protected Pojo() { + } + @Override @JsonbProperty("implementation") public String getGetterI() { @@ -82,6 +90,9 @@ public String getGetterI() { public static class PojoNoAnnotation implements WithGetterI { + protected PojoNoAnnotation() { + } + @Override public String getGetterI() { return "withGetterI"; @@ -89,10 +100,15 @@ public String getGetterI() { } public static class PojoWithDefaultSuperImplementation extends Pojo implements WithDefaultGetterI { + protected PojoWithDefaultSuperImplementation() { + } } public static class PojoWithDefaultImplementation implements WithDefaultGetterI { + protected PojoWithDefaultImplementation() { + } + @Override @JsonbProperty("defaultImplementation") public String getGetterI() { @@ -102,9 +118,13 @@ public String getGetterI() { } public static class PojoWithDefaultOnly implements WithDefaultGetterI { + protected PojoWithDefaultOnly() { + } } public static class PojoGetterDefaultedTwice extends PojoWithDefaultImplementation implements OtherWithDefaultGetterI { + protected PojoGetterDefaultedTwice() { + } } @Test diff --git a/src/test/java/org/eclipse/yasson/FieldAccessStrategyTest.java b/src/test/java/org/eclipse/yasson/FieldAccessStrategyTest.java index 725bd60c..5f8f5f01 100644 --- a/src/test/java/org/eclipse/yasson/FieldAccessStrategyTest.java +++ b/src/test/java/org/eclipse/yasson/FieldAccessStrategyTest.java @@ -23,6 +23,9 @@ public class FieldAccessStrategyTest { + private FieldAccessStrategyTest() { + } + public static class PrivateFields { private String strField; @JsonbTransient @@ -49,6 +52,10 @@ public void setStrField(String strField) { } public static class PublicFields { + + protected PublicFields() { + } + public String strField; } @@ -109,6 +116,9 @@ public void testCustomVisibityStrategy() { } public static class CustomVisibilityStrategy implements PropertyVisibilityStrategy { + public CustomVisibilityStrategy() { + } + @Override public boolean isVisible(Field field) { return field.getName().equals("stringInstance"); @@ -121,6 +131,9 @@ public boolean isVisible(Method method) { } public static class SimpleContainer { + protected SimpleContainer() { + } + private String stringInstance; private Integer integerInstance; private Float floatInstance; @@ -153,6 +166,9 @@ public void setFloatInstance(float floatInstance) { private static final class NoAccessStrategy implements PropertyVisibilityStrategy { + public NoAccessStrategy() { + } + @Override public boolean isVisible(Field field) { return false; diff --git a/src/test/java/org/eclipse/yasson/Issue454Test.java b/src/test/java/org/eclipse/yasson/Issue454Test.java index c518d999..8ba0cd04 100644 --- a/src/test/java/org/eclipse/yasson/Issue454Test.java +++ b/src/test/java/org/eclipse/yasson/Issue454Test.java @@ -22,6 +22,9 @@ public class Issue454Test { + private Issue454Test() { + } + @Test public void test() { final String EXPECTED = "{\"field2\":\"bbb\"}"; @@ -56,6 +59,10 @@ public String getField2() { } public static abstract class TheClass { + + private TheClass() { + } + @JsonbTransient public abstract String getField1(); @@ -63,6 +70,10 @@ public static abstract class TheClass { } public static class TheClass2 extends TheClass { + + private TheClass2() { + } + @Override public String getField1() { return "aaa"; diff --git a/src/test/java/org/eclipse/yasson/Issue456Test.java b/src/test/java/org/eclipse/yasson/Issue456Test.java index 52b603c0..3adc9991 100644 --- a/src/test/java/org/eclipse/yasson/Issue456Test.java +++ b/src/test/java/org/eclipse/yasson/Issue456Test.java @@ -21,6 +21,9 @@ public class Issue456Test { + private Issue456Test() { + } + @Test public void dontInvokeToString() { try { @@ -33,6 +36,9 @@ public void dontInvokeToString() { public static class Example { + protected Example() { + } + public String getProperty() { throw new RuntimeException("some error"); } diff --git a/src/test/java/org/eclipse/yasson/JavaxNamingExcludedTest.java b/src/test/java/org/eclipse/yasson/JavaxNamingExcludedTest.java index dac6960d..c5665c2c 100644 --- a/src/test/java/org/eclipse/yasson/JavaxNamingExcludedTest.java +++ b/src/test/java/org/eclipse/yasson/JavaxNamingExcludedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -27,6 +27,9 @@ */ public class JavaxNamingExcludedTest { + private JavaxNamingExcludedTest() { + } + @Test public void testNoJavaxNamingModule() { try { @@ -42,6 +45,10 @@ public void testNoJavaxNamingModule() { } public static final class AdaptedPojo { + + private AdaptedPojo() { + } + @JsonbTypeAdapter(NonCdiAdapter.class) public String adaptedValue1 = "1111"; diff --git a/src/test/java/org/eclipse/yasson/SimpleTest.java b/src/test/java/org/eclipse/yasson/SimpleTest.java index ca11319f..5a4ed0b4 100644 --- a/src/test/java/org/eclipse/yasson/SimpleTest.java +++ b/src/test/java/org/eclipse/yasson/SimpleTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -23,6 +23,9 @@ */ public class SimpleTest { + private SimpleTest() { + } + @Test public void testSimpleSerialize() { final StringWrapper wrapper = new StringWrapper(); @@ -39,6 +42,9 @@ public void testSimpleDeserializer() { public static class StringWrapper { + protected StringWrapper() { + } + public String value; public String getValue() { diff --git a/src/test/java/org/eclipse/yasson/TestTypeToken.java b/src/test/java/org/eclipse/yasson/TestTypeToken.java index 6c6c458d..621a545a 100644 --- a/src/test/java/org/eclipse/yasson/TestTypeToken.java +++ b/src/test/java/org/eclipse/yasson/TestTypeToken.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -19,6 +19,10 @@ * @author Roman Grigoriadi */ public abstract class TestTypeToken { + + protected TestTypeToken() { + } + public Type getType() { return ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; } diff --git a/src/test/java/org/eclipse/yasson/YassonConfigTest.java b/src/test/java/org/eclipse/yasson/YassonConfigTest.java index fc5eb0f8..a6bbef60 100644 --- a/src/test/java/org/eclipse/yasson/YassonConfigTest.java +++ b/src/test/java/org/eclipse/yasson/YassonConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -14,9 +14,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import jakarta.json.bind.Jsonb; -import jakarta.json.bind.JsonbBuilder; - import org.junit.jupiter.api.Test; /** @@ -24,6 +21,8 @@ */ public class YassonConfigTest { + private YassonConfigTest() {} + @SuppressWarnings("deprecation") @Test public void testFailOnUnknownPropertiesUnchanged() {