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

Bug 423591

Summary: Compiler shows errors that are not known by jdk-compiler
Product: [Eclipse Project] JDT Reporter: Missing name <andreas.deml>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED NOT_ECLIPSE QA Contact:
Severity: major    
Priority: P3 CC: stephan.herrmann
Version: 4.3.1   
Target Milestone: 4.15 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Missing name CLA 2013-12-09 09:19:30 EST
Hi,

i got a compile-error from the eclipse-compiler, that did not even give me a warning in the jdk-compiler. In the preferences i set all compile-levels to warning or ignore to make sure this is a real Eclipse-compiler-problem. 

Here is a sample-code to reproduce my error:

package test.constructortest;

import java.util.*;
import java.util.Map.Entry;

/**
 * Tests the compile-problems of eclipse.
 * 
 * @author Andreas Deml
 */
public class ConstructorTest {

    public ConstructorTest(String identifier, Object... objects) {
        this(identifier, false, objects);
    }
    
    public ConstructorTest(String identifier, Object object) {
        this (identifier, 
                object == null ? new Object[0] : new Object[] { object });
    }
    
    private ConstructorTest (String idetifier, boolean internal, Object... objects) {
        
    }
    
    public ConstructorTest() {
        
    }
    
    public ConstructorTest(Map<?, ?> input) {
        for (Entry<?, ?> entry : input.entrySet()) {
            String key = entry.getValue().toString();
            Object value = entry.getValue();
            if (!(value instanceof Object[])) {
                // compile-error: The constructor 
                // ConstructorTest(String, Object[]) is ambiguous
                this.add(new ConstructorTest(key, true, value));
            }
 
        }
    }
    
    public void add(ConstructorTest test) {
        
    }
}

Please have a look at this and try to find a solution for this concern. Thanks.

Andi
Comment 1 Eclipse Genie CLA 2020-02-12 18:04:00 EST
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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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 2 Stephan Herrmann CLA 2020-02-13 03:30:18 EST
This was a bug in javac version 6, fixed in version 7.

With recent versions, javac reports:

ConstructorTest.java:35: error: reference to ConstructorTest is ambiguous                                                                             
                this.add(new ConstructorTest(key, true, value));                                                                                      
                         ^                                                                                                                            
  both constructor ConstructorTest(String,Object...) in ConstructorTest and constructor ConstructorTest(String,boolean,Object...) in ConstructorTest match                                                                                                                                                  
1 error                                                                                                                                               


For comparison ecj's message:
----------
1. ERROR in /tmp/ConstructorTest.java (at line 35)
        this.add(new ConstructorTest(key, true, value));
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor ConstructorTest(String, Object[]) is ambiguous
----------
1 problem (1 error)