ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Murdoch <adammurd...@apache.org>
Subject Re: cvs commit: jakarta-ant/src/main/org/apache/tools/ant Main.ja va Diagnostics.java
Date Thu, 27 Jun 2002 09:51:08 GMT
On Thu, 27 Jun 2002 19:54, Stephane Bailliez wrote:
> > -----Original Message-----
> > From: Stefan Bodewig [mailto:bodewig@apache.org]
> >
> > On Thu, 27 Jun 2002, Stephane Bailliez <sbailliez@apache.org> 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:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message