-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#noissue] Remove pinpoint-commons dependency of bootstrap module
- Loading branch information
Showing
8 changed files
with
60 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...tstrap-java9/src/main/java/com/navercorp/pinpoint/bootstrap/java9/module/ModuleUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.navercorp.pinpoint.bootstrap.java9.module; | ||
|
||
import java.util.Objects; | ||
|
||
public final class ModuleUtils { | ||
private static final int CLASS_BASE_VERSION = 44; | ||
private static final int JAVA_VERSION = readJavaVersion(); | ||
|
||
public static String getPackageName(String fqcn, char packageSeparator) { | ||
Objects.requireNonNull(fqcn, "fqcn"); | ||
|
||
final int lastPackageSeparatorIndex = fqcn.lastIndexOf(packageSeparator); | ||
if (lastPackageSeparatorIndex == -1) { | ||
return null; | ||
} | ||
return fqcn.substring(0, lastPackageSeparatorIndex); | ||
} | ||
|
||
public static String toPackageName(String dirFormat) { | ||
if (dirFormat == null) { | ||
return null; | ||
} | ||
return dirFormat.replace('/', '.'); | ||
} | ||
|
||
public static int getJavaVersion() { | ||
return JAVA_VERSION; | ||
} | ||
|
||
private static int readJavaVersion() { | ||
return (int) Float.parseFloat(System.getProperty("java.class.version")) - CLASS_BASE_VERSION; | ||
} | ||
|
||
public static boolean jvmVersionUpper(int version) { | ||
return getJavaVersion() <= version; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ap-java9/src/test/java/com/navercorp/pinpoint/bootstrap/java9/module/ModuleUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.navercorp.pinpoint.bootstrap.java9.module; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class ModuleUtilsTest { | ||
|
||
@Test | ||
void isJava11JvmVersionUpper() { | ||
assertFalse(ModuleUtils.jvmVersionUpper(7)); | ||
assertFalse(ModuleUtils.jvmVersionUpper(8)); | ||
|
||
assertTrue(ModuleUtils.jvmVersionUpper(11)); | ||
assertTrue(ModuleUtils.jvmVersionUpper(17)); | ||
} | ||
} |