KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > vladium > emma > ant > IANTVersion


1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
2  *
3  * This program and the accompanying materials are made available under
4  * the terms of the Common Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
6  *
7  * $Id: IANTVersion.java,v 1.1.1.1.2.1 2004/07/10 03:34:52 vlad_r Exp $
8  */

9 package com.vladium.emma.ant;
10
11 import java.io.File JavaDoc;
12 import java.lang.reflect.Method JavaDoc;
13 import java.lang.reflect.Modifier JavaDoc;
14
15 import org.apache.tools.ant.types.FileSet;
16
17 // ----------------------------------------------------------------------------
18
/**
19  * @author Vlad Roubtsov, (C) 2004
20  */

21 public
22 interface IANTVersion
23 {
24     // public: ................................................................
25

26     /** 'true' iff the current runtime version is 1.2 or later */
27     boolean ANT_1_5_PLUS = _ANTVersion._ANT_1_5_PLUS; // static final but not inlinable
28

29     
30     abstract class _ANTVersion
31     {
32         static final boolean _ANT_1_5_PLUS; // set in <clinit>
33

34         private _ANTVersion () { /* prevent subclassing */ }
35     
36         static
37         {
38             boolean temp = true;
39             try
40             {
41                 final Method JavaDoc m = FileSet.class.getMethod ("setFile", new Class JavaDoc [] { File JavaDoc.class });
42                 
43                 // [assertion: 'm' is public]
44

45                 final int modifiers = m.getModifiers ();
46                 if ((modifiers & Modifier.STATIC) != 0)
47                     temp = false;
48             }
49             catch (NoSuchMethodException JavaDoc nsme)
50             {
51                 temp = false;
52             }
53             catch (SecurityException JavaDoc se)
54             {
55                 temp = false;
56             }
57             catch (Throwable JavaDoc t)
58             {
59                 t.printStackTrace (System.out);
60                 temp = false;
61             }
62             
63             _ANT_1_5_PLUS = temp;
64         }
65
66     } // end of nested class
67

68 } // end of interface
69
// ----------------------------------------------------------------------------
Popular Tags