Bug 241502 - java generic methods
Summary: java generic methods
Status: VERIFIED DUPLICATE of bug 238484
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.4.1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-21 04:34 EDT by gerhard presser CLA
Modified: 2009-05-07 03:32 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.