Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d80463c
fixed prematurely read issue
roterEmil Feb 1, 2024
52754a0
Merge branch 'develop' into fix/assignability-prematurelyRead
Jun 9, 2024
84281b7
Merge branch 'develop' into fix/assignability-prematurelyRead
roterEmil Jul 30, 2024
624d671
deleted sandbox files
roterEmil Jul 30, 2024
8244423
Merge branch 'fix/assignability-prematurelyRead' of https://github.co…
roterEmil Jul 30, 2024
fef5c6d
removed debug code
roterEmil Aug 1, 2024
0d76243
Update PrematurelyReadOfFinalField.java due to Dominiks review
roterEmil Sep 20, 2024
253c4fc
Update PrematurelyReadOfFinalField.java inserted line break
roterEmil Sep 20, 2024
2f1d9de
refactoring for more readability
roterEmil Oct 2, 2024
62aed1f
Merge branch 'fix/assignability-prematurelyRead' of https://github.co…
roterEmil Oct 2, 2024
9cce192
fixed multiple assignments of final fields in different branches and …
roterEmil Oct 18, 2024
4675ef7
formatting
roterEmil Oct 18, 2024
f3ba6d7
fixed grammar
roterEmil Oct 22, 2024
5fa99d8
removed commented out code
roterEmil Oct 22, 2024
7a0e320
Merge branch 'develop' into fix/assignability-prematurelyRead
roterEmil Oct 22, 2024
c261849
Merge branch 'develop' into fix/assignability-prematurelyRead
roterEmil Nov 19, 2024
e5df666
Merge branch 'develop' into fix/assignability-prematurelyRead
Aug 5, 2025
1fb4123
Fix typos and improve style
maximilianruesch Sep 16, 2025
11da1b4
Revert minimizing tests
maximilianruesch Sep 16, 2025
8cbab1f
Improve clarity on assignability analysis
maximilianruesch Sep 17, 2025
ebcb918
Merge branch 'develop' into fix/assignability-prematurelyRead
maximilianruesch Sep 17, 2025
4ed186b
Improve test case style
maximilianruesch Sep 17, 2025
adde086
Improve clarity
maximilianruesch Sep 17, 2025
13bb641
Fix formatting
maximilianruesch Sep 17, 2025
f62d034
Add missing semicolon
maximilianruesch Sep 17, 2025
13c4f87
Encapsulate assignability analysis
maximilianruesch Sep 24, 2025
df793f7
Simplify mental overhead in assignability
maximilianruesch Sep 24, 2025
9ce7d9e
Move state up
maximilianruesch Oct 2, 2025
ae0fc47
Large refactor of assignability analysis
maximilianruesch Oct 2, 2025
9126fed
Shuffle around logic
maximilianruesch Oct 3, 2025
79a8ad3
Fix typos
maximilianruesch Oct 3, 2025
518a1ce
Fix logic in meeting field assignability
maximilianruesch Oct 3, 2025
bc49ab5
More shuffling
maximilianruesch Oct 3, 2025
c5c2f5a
Fix receiver var of field domination
maximilianruesch Oct 3, 2025
891e92a
Handle domination of multiple branches
maximilianruesch Oct 3, 2025
d277036
Cleanup
maximilianruesch Oct 3, 2025
3873fe0
Analyze suspicious usages again
maximilianruesch Oct 3, 2025
05e77cf
Refactor field access structure
maximilianruesch Oct 3, 2025
22a1e18
Refine suspicious uses
maximilianruesch Oct 3, 2025
a985a4b
Enable proper updateability of field access
maximilianruesch Oct 4, 2025
c644d97
Format code
maximilianruesch Oct 4, 2025
ca9ddb2
Merge branch 'refs/heads/develop' into fix/assignability-prematurelyRead
maximilianruesch Oct 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* BSD 2-Clause License - see OPAL/LICENSE for details. */
package org.opalj.fpcf.fixtures.immutability.openworld.assignability.advanced_counter_examples;

import org.opalj.fpcf.properties.immutability.field_assignability.AssignableField;

/**
* The default value of the field x is assigned to another field n during construction and as
* a result seen with two different values.
*/
public class PrematurelyReadFinalField {

@AssignableField("Field n is assigned with different values.")
static int n = 5;

public static void main(String[] args) {
C c = new C();
}
}

class B {
B() {
PrematurelyReadFinalField.n = ((C) this).x;
}
}

class C extends B {

@AssignableField("Is seen with two different values during construction.")
public final int x;

C() {
super();
x = 3;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* BSD 2-Clause License - see OPAL/LICENSE for details. */
package org.opalj.fpcf.fixtures.immutability.openworld.assignability.advanced_counter_examples;

import org.opalj.fpcf.properties.immutability.field_assignability.AssignableField;

/**
* This test case simulates the fact that the `this` object escapes in the constructor before (final) fields
* are assigned.
*/
public class ThisEscapesDuringConstruction {

@AssignableField("The this object escapes in the constructor before the field is assigned.")
final int n;

public ThisEscapesDuringConstruction() {
C2.m(this);
n = 7;
}
}

class C2 {
public static void m(ThisEscapesDuringConstruction c) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* BSD 2-Clause License - see OPAL/LICENSE for details. */
package org.opalj.fpcf.fixtures.immutability.openworld.assignability.advanced_counter_examples;

import org.opalj.fpcf.properties.immutability.field_assignability.AssignableField;

/**
* The value of the field x is read with its default value (0)
* in the constructor before assignment and assigned to a public field.
* Thus, the value can be accessed from everywhere.
*/
public class ValueReadBeforeAssignment {
@AssignableField("Field value is read before assignment.")
private int x;
@AssignableField("Field y is public and not final.")
public int y;

public ValueReadBeforeAssignment() {
y = x;
x = 42;
}

public ValueReadBeforeAssignment foo() {
return new ValueReadBeforeAssignment();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public final class SimpleClonePattern {

@TransitivelyImmutableField("Field is effectively non assignable and has a primitive type")
@EffectivelyNonAssignableField("Field is only assigned ones due to the clone function pattern")
@EffectivelyNonAssignableField("Field is only assigned once due to the clone function pattern")
private int i;

public SimpleClonePattern clone(){
Expand All @@ -28,7 +28,7 @@ public SimpleClonePattern clone(){
class CloneNonAssignableWithNewObject {

@TransitivelyImmutableField("field is effectively non assignable and assigned with a transitively immutable object")
@EffectivelyNonAssignableField("field is only assigned ones due to the clone function pattern")
@EffectivelyNonAssignableField("field is only assigned once due to the clone function pattern")
private Integer integer;

public CloneNonAssignableWithNewObject clone(){
Expand All @@ -41,7 +41,7 @@ public CloneNonAssignableWithNewObject clone(){
class EscapesAfterAssignment {

@TransitivelyImmutableField("field is effectively non assignable and assigned with a transitively immutable object")
@EffectivelyNonAssignableField("field is only assigned ones due to the clone function pattern")
@EffectivelyNonAssignableField("field is only assigned once due to the clone function pattern")
private Integer integer;

private Integer integerCopy;
Expand Down Expand Up @@ -77,7 +77,7 @@ public MultipleFieldsAssignedInCloneFunction clone(){
class ConstructorWithParameter {

@TransitivelyImmutableField("field is effectively non assignable and has a transitively immutable type")
@EffectivelyNonAssignableField("field is only assigned ones due to the clone function pattern")
@EffectivelyNonAssignableField("field is only assigned once due to the clone function pattern")
private Integer integer;

public ConstructorWithParameter(Integer integer){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
public class DifferentLazyInitializedFieldTypes {

@TransitivelyImmutableField("Lazy initialized field with primitive type.")
@LazilyInitializedField("field is thread safely lazy initialized")
@TransitivelyImmutableField("Lazy initialized field with primitive type.")
@LazilyInitializedField("field is thread safely lazy initialized")
private int inTheGetterLazyInitializedIntField;

public synchronized int getInTheGetterLazyInitializedIntField(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ sealed trait FieldAssignability extends OrderedProperty with FieldAssignabilityP
final def key: PropertyKey[FieldAssignability] = FieldAssignability.key

def isImmutable = false

def meet(other: FieldAssignability): FieldAssignability
}

object FieldAssignability extends FieldAssignabilityPropertyMetaInformation {
Expand Down Expand Up @@ -73,9 +75,9 @@ case object EffectivelyNonAssignable extends NonAssignableField {

def meet(other: FieldAssignability): FieldAssignability =
if (other == NonAssignable) {
other
} else {
this
} else {
other
}
}

Expand Down
Loading
Loading