Bug 275471 - Eclipse Compiler needs a compile dependency to a plug-in, but javac does not need that dependency
Summary: Eclipse Compiler needs a compile dependency to a plug-in, but javac does not ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All Windows XP
: P3 blocker (vote)
Target Milestone: 3.5 RC1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-08 11:19 EDT by Ulli Hafner CLA
Modified: 2015-03-02 13:21 EST (History)
2 users (show)

See Also:
Olivier_Thomann: review+


Attachments
Proposed patch (6.95 KB, patch)
2009-05-13 15:46 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ulli Hafner CLA 2009-05-08 11:19:34 EDT
Build ID:  I20090430-2300

After upgrading to Eclipse 3.5M7 my workspace does not compile anymore, error message:
The type org.eclipse.emf.ecore.EObject cannot be resolved. It is indirectly referenced from required .class files

We are using Java 6. The following class does not compile with 3.5M7 (compiles well with 3.5M3):

package com.avaloq.ice.core.internal;

import static org.mockito.Mockito.*;
import junit.framework.TestCase;

import com.avaloq.ice.core.ISessionState;
import com.avaloq.ice.model.dbobjects.DBObject;
import com.avaloq.util.ServiceLocator;

/**
 * Tests the class {@link DataModel}.
 */
public class DataModelTest extends TestCase {
    /**
     * Checks the changed events: registration, raising and removal.
     *
     * @throws Exception the exception
     */
    public void testChangedEvent() throws Exception {
        DBObject mock = mock(DBObject.class);
        ServiceLocator.find(ISessionState.class).raiseChangedEvent(mock);
    }
}

- The classes DataModelTest and ISessionState are in plugin com.avaloq.ice.core. 
- com.avaloq.ice.core has a dependency to plugin com.avaloq.ice.model where the Interface DBObject.class is defined. 
- The type DBObject extends the EObject interface of EMF.
- The type ServiceLocator is defined in another plugin: com.avaloq.util.
- The plug-in com.avaloq.ice.model has a dependency to org.eclipse.emf.ecore, but the plugin com.avaloq.ice.core has no such dependency.

If I add a dependency of org.eclipse.emf.ecore in the plugin com.avaloq.ice.core the everything compiles. But this dependency shouldn't be required. otherwise a plugin would need all transitive dependencies of all parent classes...
Comment 1 Kent Johnson CLA 2009-05-12 15:48:33 EDT
"But this dependency shouldn't be required. otherwise a plugin would need all transitive dependencies of all parent classes..."

Actually that is exactly what it means.

The compiler needs to check more issues with Java 5 semantics that require walking up a type's hierarchy.

Likely the same as bug 269883


What is the definition of the methods mock() & raiseChangedEvent() ?
Comment 2 Ulli Hafner CLA 2009-05-13 09:21:08 EDT
Hmm, but shouldn't Eclipse be smart enough to traverse the dependency tree on its own without having an explicit dependency? Otherwise Eclipse and OSGi can't be used in projects that have more than a couple of dependencies. We compile our plug-ins with maven 2 as build tool and javac as compiler: here we don't have problems and don't need these dependencies. 

E.g., if you have a small project with one dependency to library A and that library has dependencies to libraries 1-100 then with Eclipse 3.5M7 I need to add all these dependencies to my plug-in? How do you handle that manually?
Even more, if the owner of library A decides to add additional dependencies, then I also need to manually add these! This will not work in practice.

Here some more details:

    /**
     * Creates mock object of given class or interface.
     * <p>
     * See examples in javadoc for {@link Mockito} class
     * 
     * @param classToMock class or interface to mock
     * @return mock object
     */
    public static <T> T mock(Class<T> classToMock) {
        return mock(classToMock, null, null, RETURNS_DEFAULTS);
    }
    
    /**
     * Raises an event to denote that the specified object has been changed
     * (with respect to the associations of the object). All registered
     * listeners are notified about this change in the UI thread. The changed
     * object is available in method {@link PropertyChangeEvent#getNewValue()}.
     *
     * @param object
     *            the changed object
     */
    void raiseChangedEvent(final DBObject object);


    
Comment 3 Kent Johnson CLA 2009-05-13 15:46:56 EDT
Created attachment 135668 [details]
Proposed patch

This patch changes the fix for bug 206930

We no longer will force the hierarchy of every parameter type to be resolved for an exact method match to proceed in 1.5.

Instead we will check to see if the parameter type's hierarchy has been connected, if not we will look for all possible method matches.

In a full build case, this won't cause a performance issue since all source types are connected before method sends are resolved.
Comment 4 Kent Johnson CLA 2009-05-13 15:48:00 EDT
Olivier - please review
Comment 5 Olivier Thomann CLA 2009-05-14 10:36:21 EDT
Patch looks good. +1
Comment 6 Kent Johnson CLA 2009-05-14 10:47:18 EDT
Fix released for 3.5RC1

To verify use the AmbiguousMethodTest tests added as part of 206930
Comment 7 Kent Johnson CLA 2009-05-15 10:15:11 EDT
Ulli - could please try the latest RC1 build as soon as possible to see if this fixes your problem

thx
Comment 8 Ulli Hafner CLA 2009-05-19 02:28:43 EDT
Verified with RC1: I20090515-1143.
Comment 9 Markus Keller CLA 2015-03-02 13:21:00 EST
This change caused problems and will be reverted, see bug 460993. The fix for bug 360164 actually fixed this problem in a better way.