mrstampy / Stampy

Java implementation of the STOMP 1.2 specification
67 stars 22 forks source link

Stampy is not "Java 5 compatible" #5

Closed bendoerr closed 10 years ago

bendoerr commented 10 years ago

Issue Although Stampy targets 1.5 in it's build, the 1.7 API is used by Stampy. For example AbstractStampyMessageGateway makes use of java.lang.invoke.MethodHandles which is new in Java 7. Though closer inspection it looks like any class which is logging is using java.lang.invoke.MethodHandles to reflect the class object. Thus when attempting to run a Stampy server on a JVM of lesser vintage that 1.7 you experience a NoClassDefFoundError exception which looks like the following on a 1.6 JVM:

java.lang.NoClassDefFoundError: java/lang/invoke/MethodHandles
    at asia.stampy.common.gateway.AbstractStampyMessageGateway.<clinit>(AbstractStampyMessageGateway.java:51)
    ...
Caused by: java.lang.ClassNotFoundException: java.lang.invoke.MethodHandles
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ...

Solution 1 Replace "Java 5 compatible" in the documentation with "Java 7 only" and stop targeting 1.5 for no reason.

Solution 2 Replace usages of the 1.7 API with 1.5 compatible equivalents. For example:

private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Should be replaced by
private static final Logger log = LoggerFactory.getLogger(AbstractStampyMessageGateway.class);
bendoerr commented 10 years ago

@mrstampy btw, if you could give some instructions on compiling using ant and ivy I wouldn't mind submitting a patch that really is Java 5 compatible. I've never been super familiar with ant and couldn't get anything compiled when I tried.

mrstampy commented 10 years ago

@bendoerr , thanks for the offer. If there is sufficient interest in the codebase I'll be tackling it myself, however if you are keen you can check out the project in Eclipse and install the IvyDE plugin. The build files are specific for publication of artefacts and probably won't work stand-alone.