I have two classes, generated from Scala source codes. The findbugs can process it nicely (after we tweaked some thing to get rid of obvious noises). Though it seems the error UR_UNINIT_READ_CALLED_FROM_SUPER_CONSTRUCTOR findbugs detected is actually not accurate, and this may not be Scala only problem, but possible for any explict super() call from subclasses.
Scala: 2.11.8
Java: 8
Intellij: 2016.1
Does findbugs assumes that super class ctor is always called first in subclass ctor? It may not be true generally in JVM spec (someone can classify with the latest). Since the classes are compiled by scala, we don't really have control to tweak the lines of codes to make a difference. So scala utilizes the freedom to invoke the super class <init> after the fields are initialized, especially for the parameterized non-default constructors.</init>
For example, in the dumped byte codes, the subclass assigned value for two fields on stack position 2 & 7, then call super(xyz) at sp#12. But findbugs overthere reported the above error, where calls a function indrectly that utilized the initialized field "infoExpress".
Here is the dump of byte codes (modified a little bit to make names not searchable, but I attached the classes for reproduction if needed).
public nosearch.infoex.ajax.SLInfoRow(nosearch.module.ws.infoexchange.IEDisplayListEntry, nosearch.module.ws.service.Service, boolean);
descriptor: (Lnosearch/module/ws/infoexchange/IEDisplayListEntry;Lnosearch/module/ws/service/Service;Z)V
flags: ACC_PUBLIC
Code:
stack=2, locals=4, args_size=4
0: aload_0
1: aload_2
2: putfield #21 // Field sl:Lnosearch/module/ws/service/Service;
5: aload_0
6: iload_3
7: putfield #74 // Field infoExpress:Z
10: aload_0
11: aload_1
12: invokespecial #117 // Method nosearch/infoex/ajax/InfoRow."<init>":(Lnosearch/module/ws/infoexchange/IEDisplayListEntry;)V
15: getstatic #122 // Field scala/Predef$.MODULE$:Lscala/Predef$;
18: aload_1
19: ifnonnull 26
22: iconst_0
23: goto 27
26: iconst_1
27: invokevirtual #126 // Method scala/Predef$.assert:(Z)V
30: return
LocalVariableTable:
Start Length Slot Name Signature
0 31 0 this Lnosearch/infoex/ajax/SLInfoRow;
0 31 1 ie Lnosearch/module/ws/infoexchange/IEDisplayListEntry;
0 31 2 sl Lnosearch/module/ws/service/Service;
0 31 3 infoExpress Z
LineNumberTable:
line 12: 0
line 13: 15
StackMapTable: number_of_entries = 2
frame_type = 255 / full_frame /
offset_delta = 26
locals = [ class nosearch/infoex/ajax/SLInfoRow, class nosearch/module/ws/infoexchange/IEDisplayListEntry, class nosearch/module/ws/service/Service, int ]
stack = [ class scala/Predef$ ]
frame_type = 255 / full_frame /
offset_delta = 0
locals = [ class nosearch/infoex/ajax/SLInfoRow, class nosearch/module/ws/infoexchange/IEDisplayListEntry, class nosearch/module/ws/service/Service, int ]
stack = [ class scala/Predef$, int ]</init>
The super class.