@Test public void testClassWithNoClassFile() throws IOException { assertThat(Version.getManifest(long.class)).isNull(); }
@VisibleForTesting static @Nullable Manifest getManifest(Class<?> clazz) throws IOException { URL classURL = clazz.getResource(clazz.getSimpleName() + ".class"); if (classURL == null) { logger.warn("url for class is unexpectedly null: {}", clazz); return null; } String externalForm = classURL.toExternalForm(); if (!externalForm.startsWith("jar:")) { return null; } URL manifestURL = new URL(externalForm.substring(0, externalForm.lastIndexOf('!')) + "!/META-INF/MANIFEST.MF"); return getManifest(manifestURL); }
Version { @VisibleForTesting static @Nullable Manifest getManifest(Class<?> clazz) throws IOException { URL classURL = clazz.getResource(clazz.getSimpleName() + ".class"); if (classURL == null) { logger.warn("url for class is unexpectedly null: {}", clazz); return null; } String externalForm = classURL.toExternalForm(); if (!externalForm.startsWith("jar:")) { return null; } URL manifestURL = new URL(externalForm.substring(0, externalForm.lastIndexOf('!')) + "!/META-INF/MANIFEST.MF"); return getManifest(manifestURL); } }
Version { @VisibleForTesting static @Nullable Manifest getManifest(Class<?> clazz) throws IOException { URL classURL = clazz.getResource(clazz.getSimpleName() + ".class"); if (classURL == null) { logger.warn("url for class is unexpectedly null: {}", clazz); return null; } String externalForm = classURL.toExternalForm(); if (!externalForm.startsWith("jar:")) { return null; } URL manifestURL = new URL(externalForm.substring(0, externalForm.lastIndexOf('!')) + "!/META-INF/MANIFEST.MF"); return getManifest(manifestURL); } private  Version(); }
Version { @VisibleForTesting static @Nullable Manifest getManifest(Class<?> clazz) throws IOException { URL classURL = clazz.getResource(clazz.getSimpleName() + ".class"); if (classURL == null) { logger.warn("url for class is unexpectedly null: {}", clazz); return null; } String externalForm = classURL.toExternalForm(); if (!externalForm.startsWith("jar:")) { return null; } URL manifestURL = new URL(externalForm.substring(0, externalForm.lastIndexOf('!')) + "!/META-INF/MANIFEST.MF"); return getManifest(manifestURL); } private  Version(); static String getVersion(Class<?> baseClass); static String getVersion(@Nullable URL manifestURL); }
Version { @VisibleForTesting static @Nullable Manifest getManifest(Class<?> clazz) throws IOException { URL classURL = clazz.getResource(clazz.getSimpleName() + ".class"); if (classURL == null) { logger.warn("url for class is unexpectedly null: {}", clazz); return null; } String externalForm = classURL.toExternalForm(); if (!externalForm.startsWith("jar:")) { return null; } URL manifestURL = new URL(externalForm.substring(0, externalForm.lastIndexOf('!')) + "!/META-INF/MANIFEST.MF"); return getManifest(manifestURL); } private  Version(); static String getVersion(Class<?> baseClass); static String getVersion(@Nullable URL manifestURL); static final String UNKNOWN_VERSION; }