Java类文件被截断 [英] Java class file truncated

查看:145
本文介绍了Java类文件被截断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个项目.我的一个项目(例如project2)依赖于另一个项目(project2).这两个项目都是Maven项目,而project1在project2的依赖关系中列出.当我编译project2时,应该将project1中的所有类文件都复制到project2中(我想).但是,我看到project1中一个类文件的文件大小与project2中相同类的类文件的文件大小不同.如果我反编译文件,则会得到以下结果.

I have two projects. My one project (say project2) depends on another project(project2). Both projects are maven project and project1 is listed in dependancies of project2. When I compile project2, all the class files from project1 should be copied to project2 (I imagine). But, I see that the file size of one of the class files in project1 is different than file size of class file for the same class in project2. If I decompile the files I get following results.

从project1反编译FacebookUserDetail.class:

Decompiled FacebookUserDetail.class from project1:

package com.***.domain.user.external;

import com.***.domain.user.UserDetailType;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.TypedQuery;
import org.aspectj.lang.JoinPoint;
import org.aspectj.runtime.internal.CFlowCounter;
import org.aspectj.runtime.reflect.Factory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect;
import org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect;
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl;

@Configurable
@Entity
public class FacebookUserDetail extends ExternalUserDetail
{
  public FacebookUserDetail()
  {
    JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_1, this, this); if ((!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class))) && (AbstractDependencyInjectionAspect.ajc$if$6f1(localJoinPoint))) AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
  }

  public static FacebookUserDetail findFacebookUserDetailByFacebookId(String facebookId)
  {
    String str = facebookId; JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_0, null, null, str); if ((AnnotationDrivenStaticEntityMockingControl.ajc$cflowCounter$1.isValid()) && (AnnotationDrivenStaticEntityMockingControl.hasAspect())) return (FacebookUserDetail)findFacebookUserDetailByFacebookId_aroundBody1$advice(str, localJoinPoint, AnnotationDrivenStaticEntityMockingControl.aspectOf(), null, ajc$tjp_0, localJoinPoint); return findFacebookUserDetailByFacebookId_aroundBody0(str, localJoinPoint);
  }

  public UserDetailType getExternalUserDetailType()
  {
    return UserDetailType.FACEBOOK;
  }

  static
  {
    ajc$preClinit(); } 
  public static long countFacebookUserDetails() { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$countFacebookUserDetails(); } 
  public static List<FacebookUserDetail> findAllFacebookUserDetails() { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$findAllFacebookUserDetails(); } 
  public static FacebookUserDetail findFacebookUserDetail(Long paramLong) { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$findFacebookUserDetail(paramLong); } 
  public static List<FacebookUserDetail> findFacebookUserDetailEntries(int paramInt1, int paramInt2) { return FacebookUserDetail_Roo_Entity.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Entity$com_nim_domain_user_external_FacebookUserDetail$findFacebookUserDetailEntries(paramInt1, paramInt2); } 
  public static TypedQuery<FacebookUserDetail> findFacebookUserDetailsByUserIdEquals(String paramString) { return FacebookUserDetail_Roo_Finder.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_Finder$com_nim_domain_user_external_FacebookUserDetail$findFacebookUserDetailsByUserIdEquals(paramString); } 
  public String toString() { return FacebookUserDetail_Roo_ToString.ajc$interMethod$com_nim_domain_user_external_FacebookUserDetail_Roo_ToString$com_nim_domain_user_external_FacebookUserDetail$toString(this); }

}

从project2反编译FacebookUserDetail.class

Decompiled FacebookUserDetail.class from project2

package com.***.domain.user.external;

import com.***.domain.user.UserDetailType;
import org.aspectj.lang.JoinPoint;
import org.aspectj.runtime.internal.CFlowCounter;
import org.aspectj.runtime.reflect.Factory;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.aspectj.AbstractDependencyInjectionAspect;
import org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect;
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl;

public class FacebookUserDetail extends ExternalUserDetail
{
  public FacebookUserDetail()
  {
    JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_1, this, this); if ((!AnnotationBeanConfigurerAspect.ajc$if$bb0((Configurable)getClass().getAnnotation(Configurable.class))) && (AbstractDependencyInjectionAspect.ajc$if$6f1(localJoinPoint))) AnnotationBeanConfigurerAspect.aspectOf().ajc$afterReturning$org_springframework_beans_factory_aspectj_AbstractDependencyInjectionAspect$2$1ea6722c(this);
  }

  public static FacebookUserDetail findFacebookUserDetailByFacebookId(String facebookId)
  {
    String str = facebookId; JoinPoint localJoinPoint = Factory.makeJP(ajc$tjp_0, null, null, str); if ((AnnotationDrivenStaticEntityMockingControl.ajc$cflowCounter$1.isValid()) && (AnnotationDrivenStaticEntityMockingControl.hasAspect())) return (FacebookUserDetail)findFacebookUserDetailByFacebookId_aroundBody1$advice(str, localJoinPoint, AnnotationDrivenStaticEntityMockingControl.aspectOf(), null, ajc$tjp_0, localJoinPoint); return findFacebookUserDetailByFacebookId_aroundBody0(str, localJoinPoint);
  }

  public UserDetailType getExternalUserDetailType()
  {
    return UserDetailType.FACEBOOK;
  }

  static
  {
    ajc$preClinit();
  }
}

我的问题是:project2中的类文件被截断的可能原因是什么?

My question is: What are possible reasons for truncated class file in project2?

推荐答案

关于此部分:当我编译project2时,应将project1中的所有类文件都复制到project2

实际上不是这种情况,如果项目是jar类型,则maven将两个项目编译到两个单独的jar中;如果项目2是WAR类型,则将project1.jar复制到project2的WEB-INF/lib中.

This is actually not the case, maven compiles the two projects into two separate jars if the projects are of jar type, or copies project1.jar into WEB-INF/lib of project2 if project 2 is of type WAR.

两个类文件之间的差异表明,尽管project2的版本也使用AspectJ进行了编译,但该版本并未应用Roo方面.

The difference between the two class files shows that the version of project2 does not have the Roo aspects applied to it, although it was compiled with AspectJ as well.

仅通过关闭所有IDE并尝试比较两个版本以查看是否仍然存在相同的问题,才尝试从命令行构建项目.可能是您的IDE正在使用AspectJ编译类,但没有正确的Roo方面.

Try to build the project from the command line only by closing all IDEs and compare the two versions to see if the same problem remains. It could be that your IDE is compiling the class with aspectJ but without the correct Roo aspects.

也请看一下 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆