参考:
https://blog.csdn.net/luotangsha/article/details/7016613
https://blog.csdn.net/qq_35484410/article/details/72963551
提示:
使用 Eclipse_luna_4.4.1 和 JDK7 编译
自测只有一种方式有效
要修改的文件 :
{ECLIPSE_HOME}\plugins\org.eclipse.jdt.ui_3.10.1.v20140817-1500.jar (因替换文件所以记得做备份;好像Eclipse_luna_4.4.1未使用此版本)
{ECLIPSE_HOME}}\plugins\org.eclipse.jdt.ui_3.10.2.v20141014-1419.jar (因替换文件所以记得做备份;Eclipse_luna_4.4.1运行时使用此版本)
步骤:
1.
使用 jd-gui 打开 {ECLIPSE_HOME}\plugins\org.eclipse.jdt.ui_3.10.1.v20140817-1500.jar 中 org\eclipse\jdt\internal\corext\codemanipulation\GetterSetterUtil.class
使用 jd-gui 打开 {ECLIPSE_HOME}\plugins\org.eclipse.jdt.ui_3.10.2.v20141014-1419.jar 中 org\eclipse\jdt\internal\corext\codemanipulation\GetterSetterUtil.class
2. 创建 Java 项目,并将 {ECLIPSE_HOME}}\plugins\ 目录中的所有jar包导入项目中
3. 创建 GetterSetterUtil.java
4.
将方法 getSetterStub 和 getGetterStub 中的代码
if (addComments)
{
String comment = CodeGeneration.getSetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), setterName, field.getElementName(), typeName, argname, accessorName, lineDelim);
if (comment != null)
{
buf.append(comment);
buf.append(lineDelim);
}
}
改为
if (addComments)
{
String comment = CodeGeneration.getSetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), setterName, field.getElementName(), typeName, argname, accessorName, lineDelim);
ISourceRange sr = field.getJavadocRange();
if( null != sr )
{
comment = field.getSource().substring( 0, sr.getLength() );
}
if (comment != null)
{
buf.append(comment);
buf.append(lineDelim);
}
}
5. 关闭 Eclipse
6. 将编译后的.class文件替换到对应的jar包中
使用方式: