Skip to content

Incorrectly inlines non-final variable #27

@julianhyde

Description

@julianhyde

Linq4j BlockBuilder incorrectly inlines a variable that might be assigned more than once along a code path. For example, in

long x = 0;
final long y = System.currentTimeMillis();
if (System.nanoTime() > 0L) {
  x = y;
}

it incorrectly inlines x, to yield

if (System.nanoTime() > 0L) {
  System.currentTimeMillis();
}

The fix is to only inline variables that are marked 'final'. The java compiler will ensure that they cannot be assigned more than once (by any code path) and cannot be read before they have been initialized.

This change may break code that relies on Linq4j inlining effectively final (but not explicitly final) variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions