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

Bug 241502

Summary: java generic methods
Product: [Eclipse Project] JDT Reporter: gerhard presser <gerpres>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: jerome_lanneluc, philippe_mulet
Version: 3.5   
Target Milestone: 3.4.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description gerhard presser CLA 2008-07-21 04:34:31 EDT
Hi!
following code doesn't execute properly on eclipse-ganymede.

//the remote-usable interface
public interface RemoteStore extends Remote {
    public abstract <P> P get(Class<P> c) throws RemoteException;
}

//the interface for local use
public interface Store extends RemoteStore{
    public <P> P get(Class<P> c) ;
}

//the implementation
public class StoreImpl implements Store {
    public <P> P get(Class<P> c) {
        System.out.println("get");
        return null;
    }
}

//testcases
public static void main(String[] args) {
    try {
        RemoteStore t = new StoreImpl();
        t.get(Object.class); //works
        t.get(Persistent.class); //works
        t.get(User.class); //works
    } catch (RemoteException e) {
        e.printStackTrace();
    }
    
    Store t = new StoreImpl();
    t.get(Object.class); //works
    t.get(Persistent.class); //NoSuchMethodError
    t.get(User.class); //NoSuchMethodError
} 

it works on eclipse 3.3

problem description:
I have an Interface which is used for RMI-calls. Because of that all methods have to throw RemoteException. If i use this Interface locally, it's very disturbing if you have to catch RemoteExceptions all the time, alltough you know it cannot be thrown.
I thought i write another interface which extends the Remote-Interface which overrides all the methods without the throws-declarations.
everything went fine (no compiletime errors) but when i test the methods i get NoSuchMethodErrors.
Comment 1 Kent Johnson CLA 2008-07-21 10:31:33 EDT

*** This bug has been marked as a duplicate of bug 238484 ***
Comment 2 Kent Johnson CLA 2008-08-06 15:07:14 EDT
Verified for 3.5M1 using I20080805-1307
Comment 3 Jerome Lanneluc CLA 2008-08-28 12:04:26 EDT
Cannot verify since the test case is not complete (missing Remote , RemoteException, Persistent, etc.) 

Kent why was it marked as a dup?
Comment 4 Philipe Mulet CLA 2008-08-28 12:45:57 EDT
Given kent is away.

Here is a better testcase:
//the remote-usable interface
class RemoteException extends Throwable {
}
interface RemoteStore {
	public abstract <P> P get(Class<P> c) throws RemoteException;
}
// the interface for local use
interface Store extends RemoteStore {
	public <P> P get(Class<P> c);
}
// the implementation
class StoreImpl implements Store {
	public <P> P get(Class<P> c) {
		System.out.print("[get]");
		return null;
	}
}
class Persistent {
}
public class X {
	public static void main(String[] args) {
		try {
			RemoteStore t = new StoreImpl();
			t.get(Object.class); // works
			t.get(Persistent.class); // works
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		Store t = new StoreImpl();
		t.get(Object.class); // works
		t.get(Persistent.class); // NoSuchMethodError
	}
}


It is truly a dup, since problem comes from method override with different throws clause, as addressed in bug 238484. 

Added GenericTypeTest#test1378
Comment 5 Philipe Mulet CLA 2008-08-28 12:47:25 EDT
Verified for 3.4.1 using build M20080827-2000.