1 /******************************************************************************* 2 * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors 3 * This program and the accompanying materials are made available under 4 * the terms of the Eclipse Public License 2.0 which is available at 5 * http://www.eclipse.org/legal/epl-2.0 6 * 7 * SPDX-License-Identifier: EPL-2.0 8 * 9 * Contributors: 10 * Evgeny Mandrikov - initial API and implementation 11 * 12 *******************************************************************************/ 13 package org.jacoco.core.test.validation; 14 15 /** 16 * Provides ability to detect compiler based on difference in generated bytecode 17 * for switch by enum. 18 */ 19 enum Compiler { 20 21 DETECT; 22 23 /** 24 * @return <code>true</code> if this file was compiled by javac 25 */ isJDK()26 boolean isJDK() { 27 switch (DETECT) { 28 default: 29 try { 30 Compiler.class.getDeclaredField("$SWITCH_TABLE$" 31 + Compiler.class.getName().replace('.', '$')); 32 return false; 33 } catch (NoSuchFieldException e) { 34 return true; 35 } 36 } 37 } 38 39 } 40