Skip to content

Commit

Permalink
Merge pull request #52 from OpenHFT/core/issues/662
Browse files Browse the repository at this point in the history
Add a helper method to use Class.getPackageName() , Fixes https://git…
  • Loading branch information
peter-lawrey authored Jun 12, 2024
2 parents cc21282 + 34b8761 commit 55c130b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/openhft/chronicle/values/Generators.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static String generateNativeClass(ValueModel model, String nativeClassName) {
valueBuilder.closeConstructorsAndInitializationBlocks();
TypeSpec nativeType = typeBuilder.build();
String result = JavaFile
.builder(model.valueType.getPackage().getName(), nativeType)
.builder(Jvm.getPackageName(model.valueType), nativeType)
.build()
.toString();
if (Jvm.getBoolean("chronicle.values.dumpCode"))
Expand Down Expand Up @@ -268,7 +268,7 @@ static String generateHeapClass(ValueModel model, String heapClassName) {
valueBuilder.closeConstructorsAndInitializationBlocks();
TypeSpec heapType = typeBuilder.build();
String result = JavaFile
.builder(model.valueType.getPackage().getName(), heapType)
.builder(Jvm.getPackageName(model.valueType), heapType)
.build()
.toString();
if (Jvm.getBoolean("chronicle.values.dumpCode"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package net.openhft.chronicle.values;

import net.openhft.chronicle.bytes.*;
import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.io.ClosedIllegalStateException;
import net.openhft.chronicle.core.io.IORuntimeException;
import net.openhft.chronicle.core.io.InvalidMarshallableException;
Expand Down Expand Up @@ -70,7 +71,7 @@ public MyJavaFileManager(Class<?> valueType, StandardJavaFileManager fileManager
}

private static void addFileObjects(Map<String, Set<JavaFileObject>> fileObjects, Class<?> c) {
fileObjects.compute(c.getPackage().getName(), (p, objects) -> {
fileObjects.compute(Jvm.getPackageName(c), (p, objects) -> {
if (objects == null)
objects = new HashSet<>();
objects.add(classFileObject(c));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ValueBuilder(ValueModel model, String className, TypeSpec.Builder typeBui
}

ClassName className() {
return ClassName.get(model.valueType.getPackage().getName(), className);
return ClassName.get(Jvm.getPackageName(model.valueType), className);
}

FieldSpec unsafe() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/openhft/chronicle/values/ValueModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ String simpleName() {

private Class<?> createClass(
String className, BiFunction<ValueModel, String, String> generateClass) {
String classNameWithPackage = valueType.getPackage().getName() + "." + className;
String classNameWithPackage = Jvm.getPackageName(valueType) + "." + className;
ClassLoader cl = BytecodeGen.getClassLoader(valueType);
try {
return cl.loadClass(classNameWithPackage);
Expand Down

0 comments on commit 55c130b

Please sign in to comment.