I defined Point class like below.
package com.sample.app.model;
public class Point {
public int x;
public int y;
}
When I try to construct other class with Point class data, I seen package name is corrupted.
CtClass pointClass = classPool.getAndRename("com.sample.app.model.Point", "com.sample.app.model.MyPoint");
Generated MyPoint.class code looks like below.
package model;
public class MyPoint {
public int x;
public int y;
}
As you see above snippet, package name is given as model, instead of "com.sample.app.model".
Surprisingly, When I print the new class name, it prints the package name correctly.
Class<?> myPointClass = pointClass.toClass();
System.out.println(myPointClass.getName());
But When I decompile the class file using Java decompiler, I see package name corruption.