Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 496786

Summary: Eclipse compiler accepts invalid syntax without error
Product: [Eclipse Project] JDT Reporter: Alessandro Nistico <alienisty>
Component: CoreAssignee: Srikanth Sankaran <srikanth.sankaran>
Status: CLOSED MOVED QA Contact:
Severity: normal    
Priority: P3 CC: manoj.palat, srikanth.sankaran, stephan.herrmann
Version: 4.6   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Alessandro Nistico CLA 2016-06-26 07:27:55 EDT
The following Java code is accepted without errors by eclipse:

public class EclipseParserBug {
  private static void copy(boolean[] src, boolean[] dst) {
    long start=System.nanoTime();
    IntStream.range(0, src.length).parallel().forEach(i -> dst[i] = src[i]))); 	  
    System.out.println("Copy took: " + (System.nanoTime() - start));
  }
}

which is compiled in the following byte code:

// Compiled from EclipseParserBug.java (version 1.8 : 52.0, super bit)
public class EclipseParserBug {
  
  // Method descriptor #6 ()V
  // Stack: 1, Locals: 1
  public EclipseParserBug();
    0  aload_0 [this]
    1  invokespecial java.lang.Object() [8]
    4  return
      Line numbers:
        [pc: 0, line: 1]
      Local variable table:
        [pc: 0, pc: 5] local: this index: 0 type: EclipseParserBug
  
  // Method descriptor #15 ([Z[Z)V
  // Stack: 2, Locals: 4
  private static void copy(boolean[] src, boolean[] dst);
    0  invokestatic java.lang.System.nanoTime() : long [16]
    3  lstore_2 [start]
    4  return
      Line numbers:
        [pc: 0, line: 3]
        [pc: 4, line: 8]
      Local variable table:
        [pc: 0, pc: 5] local: src index: 0 type: boolean[]
        [pc: 0, pc: 5] local: dst index: 1 type: boolean[]
        [pc: 4, pc: 5] local: start index: 2 type: long
}

which is also incorrect.

Note how only the first line of the source code has been compiled, despite having debug information for the rest.

It seems like a very corner case but it could lead to very sneaky and hard to find bugs.
Comment 1 Stephan Herrmann CLA 2016-06-28 18:18:27 EDT
The bug happens all the way back to our first version supporting Java 8.
Comment 2 Manoj N Palat CLA 2018-05-17 03:25:26 EDT
bulk move out of 4.8
Comment 3 Eclipse Genie CLA 2022-06-01 17:06:29 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Srikanth Sankaran CLA 2023-06-01 06:29:46 EDT
Fixed here: https://github.com/eclipse-jdt/eclipse.jdt.core/issues/367