On Thu, 27 Jun 2002 19:54, Stephane Bailliez wrote:
> > -----Original Message-----
> > From: Stefan Bodewig [mailto:[EMAIL PROTECTED]
> >
> > On Thu, 27 Jun 2002, Stephane Bailliez <[EMAIL PROTECTED]> wrote:
> >
> > BTW, there seems to be some funny classloader stuff going on as well,
> > can you shed some light on
> > <http://cvs.apache.org/~bodewig/gump/20020627/test-ant.html>?
>
> Only if you tell me what's wrong with this code in JDK 1.2+, that must be
> damn stupid. �$*# !
> I keep having nosuchmethod...<g> that must be sooo simple !
>
>     private static String getImplementationVersion(Class clazz){
>         try {
>           // Package pkg = clazz.getPackage();
>           Method method = clazz.getMethod("getPackage", new Class[0]);

method = Class.class.getMethod( ... );
pkg = method.invoke(clazz,null);

>           Object pkg = method.invoke(null, null);
>           if (pkg != null) {
>               // pkg.getImplementationVersion();
>               method = pkg.getClass().getMethod("getImplementationVersion",
> new Class[0]);
>               Object version = method.invoke(pkg, null);
>               return (String)version;
>           }
>         } catch (Exception e){
>           e.printStackTrace();
>           // JDK < 1.2 should land here because the method above don't
> exist.
>           return "?.?";
>         }
>         return null;
>     }

-- 
Adam

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to