1,675 questions
Score of 3
0 answers
141 views
Jackson 3 and final Map deserialization
In a corporate project, I’m migrating from Spring 3.x to Spring 4.x, and also from Jackson 2.x to 3.x at the same time.
I do have the following problem: with Jackson 2 this code works "as is"...
Score of 2
1 answer
180 views
Why calling static field with the class is different from use just the variable name? [duplicate]
Consider the following code:
public class Example {
static { System.out.println(Example.value); }
static final int value = 7;
public static void main(final String[] args) { }
}
...
Score of 4
3 answers
894 views
Can you set value of a private final variable in Java 21?
This used to be easy in Java 8 and I want to know if it's still possible in Java 21. I've seen a bunch of old posts, all giving different methods for this, none of which worked. I'm hoping for a ...
Score of 2
1 answer
2813 views
Implicitly declared classes in IntellijIDEA - how to deactivate that feature
First of all, I am a beginner in programming, so please don't expect me to now a lot about this.
I am working on a project for my programming course in computer science, where we use JUnit for tests ...
Score of 2
1 answer
313 views
How does Spring make a service class open? I thought Kotlin is final by default
The methods or classes in Kotlin are final by default. But when I mark a method in a Service class to be @Transactional, I realised the service class and all its methods are open. Because for the @...
Score of 0
1 answer
94 views
Final variables "might not have been initialized" in a multiple-constructor class
I have a class with two different final variables and two different constructors.
public class Parent {
private final String name;
private final String dob;
public Parent() {
...
Score of 0
1 answer
60 views
Dart: multiplying string Error: In constant expressions, operands of this operator must be of type 'num'
I was attempting to test a simple piece of code involving multiplying the constant name by 20
however I noticed I had issues when I entered this code with constants:
void test() {
const String name ...
Score of 4
1 answer
163 views
In which scenario are non-final non-virtual classes like std::-classes useful?
A base class in C++ should have at least a virtual destructor, if I inherit from the class. Therefore, one should e.g. better not inherit from std::optional.
The answer here says
If it doesn't have ...
Score of 0
1 answer
78 views
Can't change accessibility to field in unit test . getDeclaredField can't find my field [duplicate]
I have the problem that my getDeclaredField can't find my field, and I can't find why. Any ideas?
public interface MapInterface<K extends Comparable<K>, V> {
public void setValue(K ...
Score of 2
2 answers
99 views
Is there a way to tell at runtime whether a Java final field is a constant?
I'd like to be able to differentiate at runtime (presumably using reflection), between these two cases, where the former has a final field defined at initialization (i.e. a constant), and the latter ...
Score of 6
0 answers
95 views
Make a method final and use the base class implementation
I have a hierarchy of polymorphic classes. At some level in the hierarchy, I want to make the implementation of a virtual method final.
Additionally, I just want to use the base class implementation.
...
Score of 3
2 answers
132 views
java final field may already be assigned: compiler bug?
I have the following class:
public class FileId {
final long length;
final String hash;
FileId(File file) {
assert !file.isDirectory();
this.length = file.length();
...
Score of 0
2 answers
82 views
Different behavior when using const before a const constructor in Dart
In the Dart documentation, it states that we should not place const before initializing a const constructor, as the keyword is already implicit.
However, can someone explain why the following codes ...
Score of 1
1 answer
286 views
Is there a good way to make runtime constants within methods in C#?
I really enjoy how in Java, we can declare variables "final" within methods to indicate that they will not change after initialization. In C#, you cannot do this same thing-- the only ...
Score of 2
1 answer
132 views
How to prevent override methods from being converted into final in R8?
I am facing an issue while using R8 in my Android project. It seems that all the override methods in my code are automatically being converted into final methods. This behavior is causing problems as ...