private static String getAdditionalJvmLanguages() { StringBuilder versions = new StringBuilder(); concat(versions, scalaVersion(), " "); concat(versions, clojureVersion(), " "); concat(versions, groovyVersion(), " "); concat(versions, jythonVersion(), " "); concat(versions, jrubyVersion(), " "); concat(versions, kotlinVersion(), " "); return versions.toString(); }
private static String kotlinVersionByClass() { StringBuilder kotlinVersion = new StringBuilder(""); try { Class<?> versionClass = Class.forName("kotlin.KotlinVersion"); kotlinVersion.append("kotlin"); String version = versionClass.getField("CURRENT").get(null).toString(); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //ignore } catch (Exception e) { if (log.isTraceEnabled()){ log.trace("Exception attempting to get Kotlin version.", e); } } return kotlinVersion.toString(); }
private static String kotlinVersionByJar() { StringBuilder kotlinVersion = new StringBuilder(""); JarInputStream kotlinJar = null; try { Class<?> kotlinUnit = Class.forName("kotlin.Unit"); kotlinVersion.append("kotlin"); kotlinJar = new JarInputStream(kotlinUnit.getProtectionDomain().getCodeSource().getLocation().openStream()); String version = kotlinJar.getManifest().getMainAttributes().getValue("Implementation-Version"); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception attempting to get Kotlin version.", e); } } finally { closeQuietly(kotlinJar, log); } return kotlinVersion.toString(); }
/** * Attempt to determine if this language exists on the classpath and what it's version is * @param language the name of the language * @param className a class of that lanauge that exposes runtime version information * @param methodOrFieldName the static field or method name that holds the version number * @param isMethod whether the above is a field or method * @return the version number or empty string if the language does not exist on the classpath */ private static String languageVersion(String language, String className, String methodOrFieldName, boolean isMethod) { StringBuilder sb = new StringBuilder(); try { Class<?> clz = Class.forName(className); sb.append(language); String version = isMethod ? (String) clz.getMethod(methodOrFieldName).invoke(null) : (String) clz.getField(methodOrFieldName).get(null); concat(sb, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()){ log.trace("Exception attempting to get " + language + " version.", e); } } return sb.toString(); }
private static String getAdditionalJvmLanguages() { StringBuilder versions = new StringBuilder(); concat(versions, scalaVersion(), " "); concat(versions, clojureVersion(), " "); concat(versions, groovyVersion(), " "); concat(versions, jythonVersion(), " "); concat(versions, jrubyVersion(), " "); concat(versions, kotlinVersion(), " "); return versions.toString(); }
private static String kotlinVersionByClass() { StringBuilder kotlinVersion = new StringBuilder(""); try { Class<?> versionClass = Class.forName("kotlin.KotlinVersion"); kotlinVersion.append("kotlin"); String version = versionClass.getField("CURRENT").get(null).toString(); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //ignore } catch (Exception e) { if (log.isTraceEnabled()){ log.trace("Exception attempting to get Kotlin version.", e); } } return kotlinVersion.toString(); }
/** * Attempt to determine if this language exists on the classpath and what it's version is * @param language the name of the language * @param className a class of that lanauge that exposes runtime version information * @param methodOrFieldName the static field or method name that holds the version number * @param isMethod whether the above is a field or method * @return the version number or empty string if the language does not exist on the classpath */ private static String languageVersion(String language, String className, String methodOrFieldName, boolean isMethod) { StringBuilder sb = new StringBuilder(); try { Class<?> clz = Class.forName(className); sb.append(language); String version = isMethod ? (String) clz.getMethod(methodOrFieldName).invoke(null) : (String) clz.getField(methodOrFieldName).get(null); concat(sb, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()){ log.trace("Exception attempting to get " + language + " version.", e); } } return sb.toString(); }
private static String kotlinVersionByJar() { StringBuilder kotlinVersion = new StringBuilder(""); JarInputStream kotlinJar = null; try { Class<?> kotlinUnit = Class.forName("kotlin.Unit"); kotlinVersion.append("kotlin"); kotlinJar = new JarInputStream(kotlinUnit.getProtectionDomain().getCodeSource().getLocation().openStream()); String version = kotlinJar.getManifest().getMainAttributes().getValue("Implementation-Version"); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception attempting to get Kotlin version.", e); } } finally { closeQuietly(kotlinJar, log); } return kotlinVersion.toString(); }
private static String getAdditionalJvmLanguages() { StringBuilder versions = new StringBuilder(); concat(versions, scalaVersion(), " "); concat(versions, clojureVersion(), " "); concat(versions, groovyVersion(), " "); concat(versions, jythonVersion(), " "); concat(versions, jrubyVersion(), " "); concat(versions, kotlinVersion(), " "); return versions.toString(); }
private static String kotlinVersionByClass() { StringBuilder kotlinVersion = new StringBuilder(""); try { Class<?> versionClass = Class.forName("kotlin.KotlinVersion"); kotlinVersion.append("kotlin"); String version = versionClass.getField("CURRENT").get(null).toString(); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //ignore } catch (Exception e) { if (log.isTraceEnabled()){ log.trace("Exception attempting to get Kotlin version.", e); } } return kotlinVersion.toString(); }
/** * Attempt to determine if this language exists on the classpath and what it's version is * @param language the name of the language * @param className a class of that lanauge that exposes runtime version information * @param methodOrFieldName the static field or method name that holds the version number * @param isMethod whether the above is a field or method * @return the version number or empty string if the language does not exist on the classpath */ private static String languageVersion(String language, String className, String methodOrFieldName, boolean isMethod) { StringBuilder sb = new StringBuilder(); try { Class<?> clz = Class.forName(className); sb.append(language); String version = isMethod ? (String) clz.getMethod(methodOrFieldName).invoke(null) : (String) clz.getField(methodOrFieldName).get(null); concat(sb, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()){ log.trace("Exception attempting to get " + language + " version.", e); } } return sb.toString(); }
private static String kotlinVersionByJar() { StringBuilder kotlinVersion = new StringBuilder(""); JarInputStream kotlinJar = null; try { Class<?> kotlinUnit = Class.forName("kotlin.Unit"); kotlinVersion.append("kotlin"); kotlinJar = new JarInputStream(kotlinUnit.getProtectionDomain().getCodeSource().getLocation().openStream()); String version = kotlinJar.getManifest().getMainAttributes().getValue("Implementation-Version"); concat(kotlinVersion, version, "/"); } catch (ClassNotFoundException e) { //Ignore } catch (Exception e) { if (log.isTraceEnabled()) { log.trace("Exception attempting to get Kotlin version.", e); } } finally { closeQuietly(kotlinJar, log); } return kotlinVersion.toString(); }