当前位置: 首页>>代码示例>>Java>>正文


Java SerializationUtils.isSerializable方法代码示例

本文整理汇总了Java中com.siyeh.ig.psiutils.SerializationUtils.isSerializable方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationUtils.isSerializable方法的具体用法?Java SerializationUtils.isSerializable怎么用?Java SerializationUtils.isSerializable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.siyeh.ig.psiutils.SerializationUtils的用法示例。


在下文中一共展示了SerializationUtils.isSerializable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitMethod

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  // no call to super, so it doesn't drill down
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.PROTECTED)) {
    return;
  }
  if (aClass.hasModifierProperty(PsiModifier.FINAL) &&
      method.hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  if (!SerializationUtils.isReadResolve(method) &&
      !SerializationUtils.isWriteReplace(method)) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:ReadResolveAndWriteReplaceProtectedInspection.java

示例2: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  final PsiField field =
    aClass.findFieldByName(
      HardcodedMethodConstants.SERIAL_VERSION_UID, false);
  if (field == null) {
    return;
  }
  final PsiType type = field.getType();
  final boolean wrongType = !PsiType.LONG.equals(type);
  if (field.hasModifierProperty(PsiModifier.STATIC) &&
      field.hasModifierProperty(PsiModifier.PRIVATE) &&
      field.hasModifierProperty(PsiModifier.FINAL) &&
      !wrongType) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerFieldError(field, Boolean.valueOf(wrongType));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SerialVersionUIDNotStaticFinalInspection.java

示例3: visitField

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitField(PsiField field) {
  super.visitField(field);
  if (!field.hasModifierProperty(PsiModifier.TRANSIENT)) {
    return;
  }
  final PsiClass containingClass = field.getContainingClass();
  if (!SerializationUtils.isSerializable(containingClass)) {
    return;
  }
  final PsiExpression initializer = field.getInitializer();
  if (initializer == null &&
      !isInitializedInInitializer(field, containingClass) &&
      !isInitializedInConstructors(field, containingClass)) {
    return;
  }
  if (SerializationUtils.hasReadObject(containingClass)) {
    return;
  }
  registerFieldError(field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:TransientFieldNotInitializedInspection.java

示例4: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
    return;
  }
  if (aClass instanceof PsiTypeParameter || aClass instanceof PsiEnumConstantInitializer) {
    return;
  }
  if (ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) {
    return;
  }
  final PsiField serialVersionUIDField = aClass.findFieldByName(HardcodedMethodConstants.SERIAL_VERSION_UID, false);
  if (serialVersionUIDField != null) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  if (SerializationUtils.hasWriteReplace(aClass)) {
    return;
  }
  if (isIgnoredSubclass(aClass)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SerializableHasSerialVersionUIDFieldInspectionBase.java

示例5: visitMethod

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  // no call to super, so it doesn't drill down
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  if (method.hasModifierProperty(PsiModifier.PRIVATE)) {
    return;
  }
  if (!SerializationUtils.isReadObject(method) &&
      !SerializationUtils.isWriteObject(method)) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerMethodError(method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ReadObjectAndWriteObjectPrivateInspection.java

示例6: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass) || SerializationUtils.hasWriteReplace(aClass)) {
    return;
  }
  PsiClass ancestor = aClass.getSuperClass();
  final Set<PsiClass> visitedClasses = new HashSet<PsiClass>(8);
  while (ancestor != null && SerializationUtils.isSerializable(ancestor)) {
    if (SerializationUtils.hasWriteReplace(ancestor)) {
      return;
    }
    ancestor = ancestor.getSuperClass();
    if (!visitedClasses.add(ancestor)) {
      return;
    }
  }
  if (ancestor == null || classHasNoArgConstructor(ancestor)) {
    return;
  }
  registerClassError(aClass, ancestor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SerializableWithUnconstructableAncestorInspection.java

示例7: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
    return;
  }
  if (aClass instanceof PsiTypeParameter || !SerializationUtils.isSerializable(aClass)) {
    return;
  }
  final PsiMethod[] methods = aClass.getMethods();
  for (final PsiMethod method : methods) {
    if (!SerializationUtils.isReadObject(method)) {
      continue;
    }
    if (ControlFlowUtils.methodAlwaysThrowsException(method)) {
      return;
    }
    else {
      break;
    }
  }
  if (ignoreThrowable && InheritanceUtil.isInheritor(aClass, false, "java.lang.Throwable")) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DeserializableClassInSecureContextInspection.java

示例8: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
    return;
  }
  if (aClass instanceof PsiTypeParameter || !SerializationUtils.isSerializable(aClass)) {
    return;
  }
  final PsiMethod[] methods = aClass.findMethodsByName("writeObject", true);
  for (final PsiMethod method : methods) {
    if (!SerializationUtils.isWriteObject(method)) {
      continue;
    }
    if (ControlFlowUtils.methodAlwaysThrowsException((PsiMethod)method.getNavigationElement())) {
      return;
    }
    else {
      break;
    }
  }
  if (ignoreThrowable && InheritanceUtil.isInheritor(aClass, false, "java.lang.Throwable")) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SerializableClassInSecureContextInspection.java

示例9: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  final boolean hasReadObject =
    SerializationUtils.hasReadObject(aClass);
  final boolean hasWriteObject =
    SerializationUtils.hasWriteObject(aClass);
  if (!hasWriteObject && !hasReadObject) {
    return;
  }
  if (SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerClassError(aClass, Boolean.valueOf(hasReadObject),
                     Boolean.valueOf(hasWriteObject), aClass);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:NonSerializableWithSerializationMethodsInspection.java

示例10: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
    return;
  }
  if (aClass instanceof PsiTypeParameter) {
    return;
  }
  if (inspection.ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) {
    return;
  }
  if (aClass.findFieldByName(HardcodedMethodConstants.SERIAL_VERSION_UID, false) != null) {
    return;
  }
  final PsiClass containingClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class);
  if (containingClass == null) {
    return;
  }
  if (aClass.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiModifierListOwner staticElement = PsiUtil.getEnclosingStaticElement(aClass, containingClass);
  if (staticElement != null) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  if (inspection.isIgnoredSubclass(aClass)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:SerializableInnerClassHasSerialVersionUIDFieldVisitor.java

示例11: visitField

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
  if (field.hasModifierProperty(PsiModifier.TRANSIENT) || field.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiClass aClass = field.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  if (SerializationUtils.isProbablySerializable(field.getType())) {
    return;
  }
  final boolean hasWriteObject = SerializationUtils.hasWriteObject(aClass);
  if (hasWriteObject) {
    return;
  }
  if (isIgnoredSubclass(aClass)) {
    return;
  }
  if (AnnotationUtil.isAnnotated(field, ignorableAnnotations)) {
    return;
  }
  registerFieldError(field, field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:NonSerializableFieldInSerializableClassInspectionBase.java

示例12: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  final PsiField field = aClass.findFieldByName(HardcodedMethodConstants.SERIAL_VERSION_UID, false);
  if (field == null) {
    return;
  }
  if (SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerClassError(aClass, aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:NonSerializableWithSerialVersionUIDFieldInspection.java

示例13: visitField

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitField(@NotNull PsiField field) {
  if (!field.hasModifierProperty(PsiModifier.TRANSIENT)) {
    return;
  }
  final PsiClass aClass = field.getContainingClass();
  if (SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerModifierError(PsiModifier.TRANSIENT, field, field);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:TransientFieldInNonSerializableClassInspection.java

示例14: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  // no call to super, so it doesn't drill down
  if (aClass.isInterface() || aClass.isAnnotationType()) {
    return;
  }
  PsiField badSerialPersistentFields = null;
  final PsiField[] fields = aClass.getFields();
  for (final PsiField field : fields) {
    if (isSerialPersistentFields(field)) {
      if (!field.hasModifierProperty(PsiModifier.PRIVATE) ||
          !field.hasModifierProperty(PsiModifier.STATIC) ||
          !field.hasModifierProperty(PsiModifier.FINAL)) {
        badSerialPersistentFields = field;
        break;
      }
      else {
        final PsiType type = field.getType();
        if (!type.equalsToText("java.io.ObjectStreamField" +
                               "[]")) {
          badSerialPersistentFields = field;
          break;
        }
      }
    }
  }
  if (badSerialPersistentFields == null) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  registerFieldError(badSerialPersistentFields);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:SerialPersistentFieldsWithWrongSignatureInspection.java

示例15: visitClass

import com.siyeh.ig.psiutils.SerializationUtils; //导入方法依赖的package包/类
@Override
public void visitClass(@NotNull PsiClass aClass) {
  if (aClass.isInterface() || aClass.isAnnotationType() || aClass.isEnum()) {
    return;
  }
  if (aClass instanceof PsiTypeParameter) {
    return;
  }
  if (inspection.ignoreAnonymousInnerClasses && aClass instanceof PsiAnonymousClass) {
    return;
  }
  final PsiClass containingClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class);
  if (containingClass == null) {
    return;
  }
  if (aClass.hasModifierProperty(PsiModifier.STATIC)) {
    return;
  }
  final PsiModifierListOwner staticElement = PsiUtil.getEnclosingStaticElement(aClass, containingClass);
  if (staticElement != null) {
    return;
  }
  if (!SerializationUtils.isSerializable(aClass)) {
    return;
  }
  if (SerializationUtils.isSerializable(containingClass)) {
    return;
  }
  if (inspection.isIgnoredSubclass(aClass)) {
    return;
  }
  registerClassError(aClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SerializableInnerClassWithNonSerializableOuterClassVisitor.java


注:本文中的com.siyeh.ig.psiutils.SerializationUtils.isSerializable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。