IANTVersion.java revision f6fe897e173f4e4bda72a7dddb091b667066764a
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 */ 9package com.vladium.emma.ant; 10 11import java.io.File; 12import java.lang.reflect.Method; 13import java.lang.reflect.Modifier; 14 15import org.apache.tools.ant.types.FileSet; 16 17// ---------------------------------------------------------------------------- 18/** 19 * @author Vlad Roubtsov, (C) 2004 20 */ 21public 22interface 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 m = FileSet.class.getMethod ("setFile", new Class [] { File.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 nsme) 50 { 51 temp = false; 52 } 53 catch (SecurityException se) 54 { 55 temp = false; 56 } 57 catch (Throwable 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// ----------------------------------------------------------------------------