Compile errors under JDK 1.5? It compiles fine under 1.4.x

Can someone please try to compile these two classes under JDK 1.5.. the same exact code compiles under 1.4.x...

import javax.security.auth.spi.LoginModule;

import javax.security.auth.Subject;

import javax.security.auth.login.LoginException;

import javax.security.auth.callback.CallbackHandler;

import java.util.Map;

/**

* Simple abstract login module

*/

public abstract class AbstractLoginModule implements LoginModule {

protected Subject subject;

protected CallbackHandler callbackHandler;

protected Map sharedState;

protected Map options;

protected abstract boolean doAuthenticate(String user, String password) throws LoginException;

public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {

this.subject = subject;

this.callbackHandler = callbackHandler;

this.sharedState = sharedState;

this.options = options;

}

public boolean login() throws LoginException {

return false; //To change body of implemented methods use File | Settings | File Templates.

}

public boolean commit() throws LoginException {

return false; //To change body of implemented methods use File | Settings | File Templates.

}

public boolean abort() throws LoginException {

return false; //To change body of implemented methods use File | Settings | File Templates.

}

public boolean logout() throws LoginException {

return false; //To change body of implemented methods use File | Settings | File Templates.

}

}

// DUMMY LOGINMODULE.java

import javax.security.auth.login.LoginException;

import javax.security.auth.Subject;

import javax.security.auth.callback.CallbackHandler;

import java.util.Map;

/**

* Simple subclass of AbstractLoginModule

*/

public class DummyLoginModule extends AbstractLoginModule {

public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) {

// This line doesn't compile under JDK 1.5 for some reason

super.initialize(subject, callbackHandler, sharedState, options);

}

protected boolean doAuthenticate(String user, String password) throws LoginException {

return false;

}

}

Here is what I get when trying to compile...

C:\Documents and Settings\tmulle\IdeaProjects\AbstractTest\src>"%JAVA_HOME%\bin\javac.exe" *.java -Xlint -d ..\classes

DummyLoginModule.java:17: abstract method initialize(javax.security.auth.Subject,javax.security.auth.callback.CallbackHandler,java.util.Map<java.lang.String,?>,java.util.Map<java.lang.String,?>) in ja

vax.security.auth.spi.LoginModule cannot be accessed directly

super.initialize(subject, callbackHandler, sharedState, options);

^

DummyLoginModule.java:17: warning: [unchecked] unchecked conversion

found : java.util.Map

required: java.util.Map<java.lang.String,?>

super.initialize(subject, callbackHandler, sharedState, options);

^

DummyLoginModule.java:17: warning: [unchecked] unchecked conversion

found : java.util.Map

required: java.util.Map<java.lang.String,?>

super.initialize(subject, callbackHandler, sharedState, options);

^

1 error

2 warnings

Thanks...

[3439 byte] By [tmulle] at [2007-9-30 19:38:50]
# 1
The specification for the interfaces/abstract classes changed.You will need to add the new methods or it will not compile in 1.5.You can continue to compile the modules in 1.4 and then just use the compiled forms in 1.5
jschell at 2007-7-7 0:23:46 > top of Java-index,Administration Tools,Sun Connection...
# 2

JSchell,

Thanks, that's very interesting... so it sounds like JDK1.5 is binary backward compatible with JDK1.4 in respect to generics with some sort of conversion going on when running 1.4 code under 1.5, but is not source code compatible without modifications to reflect new changes...

I guess because the interface for LoginModule declares a generic (i.e. Map<String,?>) that I'm forced to provide one to it instead of say Map m = new HashMap(); ?

Thanks...

tmulle at 2007-7-7 0:23:46 > top of Java-index,Administration Tools,Sun Connection...
# 3

> JSchell,

>

> Thanks, that's very interesting... so it sounds like

> JDK1.5 is binary backward compatible with JDK1.4 in

> respect to generics with some sort of conversion going

> on when running 1.4 code under 1.5, but is not source

> code compatible without modifications to reflect new

> changes...

That is a bit inprecise.

The interface has changed. That is what you are seeing.

The fact that the interface now uses generics (which might be the sole reason or a partial reason for the change) is not the significant part.

The same thing has happened for previous VM versions.

>

> I guess because the interface for LoginModule declares

> a generic (i.e. Map<String,?>) that I'm forced to

> provide one to it instead of say Map m = new

> HashMap(); ?

You must provide what ever the interface requires.

jschell at 2007-7-7 0:23:46 > top of Java-index,Administration Tools,Sun Connection...