diff --git a/TracerOnJavassist/src/tracer/OutputStatementsGenerator.java b/TracerOnJavassist/src/tracer/OutputStatementsGenerator.java index 700afcc..12ef3d2 100644 --- a/TracerOnJavassist/src/tracer/OutputStatementsGenerator.java +++ b/TracerOnJavassist/src/tracer/OutputStatementsGenerator.java @@ -31,19 +31,26 @@ return generator; } - public String generateReplaceStatementsForFieldSet(CtClass cc, FieldAccess f, int line) { + public String generateReplaceStatementsForFieldSet(CtClass cc, FieldAccess f, int line) throws NotFoundException { String fieldName = "\"" + f.getClassName() + "." + f.getFieldName() + "\""; String containerClass = "(($0 != null)?$0.getClass().getName():\"" + cc.getName() + "\")"; String containerObject = "(($0 != null)?System.identityHashCode($0):0)"; - String valueClass = "(($1 != null)?$1.getClass().getName():\"---\")"; - String valueObject = "(($1 != null)?System.identityHashCode($1):0)"; + String valueClass; + String valueObject; + if (!f.getField().getType().isPrimitive()) { + valueClass = "(($1 != null)?$1.getClass().getName():\"---\")"; + valueObject = "(($1 != null)?System.identityHashCode($1):0)"; + } else { + valueClass = "\"" + f.getField().getType().getName() + "\""; // ��{�^�̏ꍇ�AgetClass()�ł��Ȃ����� + valueObject = "$1"; + } String threadId = "Thread.currentThread().getId()"; String lineNum = "\"" + line + "\""; String timeStamp = "System.nanoTime()"; return generator.generateReplaceStatementsForFieldSet(fieldName, containerClass, containerObject, valueClass, valueObject, threadId, lineNum, timeStamp); } - public String generateReplaceStatementsForFieldGet(CtClass cc, CtBehavior m, FieldAccess f, int line) { + public String generateReplaceStatementsForFieldGet(CtClass cc, CtBehavior m, FieldAccess f, int line) throws NotFoundException { String fieldName = "\"" + f.getClassName() + "." + f.getFieldName() + "\""; String thisClass; String thisObject; @@ -57,8 +64,15 @@ } String containerClass = "(($0 != null)?$0.getClass().getName():\"---\")"; String containerObject = "(($0 != null)?System.identityHashCode($0):0)"; - String valueClass = "(($_ != null)?$_.getClass().getName():\"---\")"; - String valueObject = "(($_ != null)?System.identityHashCode($_):0)"; + String valueClass; + String valueObject; + if (!f.getField().getType().isPrimitive()) { + valueClass = "(($_ != null)?$_.getClass().getName():\"---\")"; + valueObject = "(($_ != null)?System.identityHashCode($_):0)"; + } else { + valueClass = "\"" + f.getField().getType().getName() + "\""; // ��{�^�̏ꍇ�AgetClass()�ł��Ȃ����� + valueObject = "$_"; + } String threadId = "Thread.currentThread().getId()"; String lineNum = "\"" + line + "\""; String timeStamp = "System.nanoTime()"; @@ -222,7 +236,7 @@ thisClass = "this.getClass().getName()"; thisObject = "System.identityHashCode(this)"; } else { - returnedClass = "\"" + ((CtMethod)m).getReturnType().getName() +"\""; + returnedClass = "\"" + ((CtMethod)m).getReturnType().getName() +"\""; // ��{�^�̏ꍇ�AgetClass()�ł��Ȃ����� returnedObject = "$_"; thisClass = "this.getClass().getName()"; thisObject = "System.identityHashCode(this)"; @@ -235,7 +249,7 @@ thisClass = "$0.getClass().getName()"; thisObject = "System.identityHashCode($0)"; } else { - returnedClass = "\"" + ((CtMethod)m).getReturnType().getName() +"\""; + returnedClass = "\"" + ((CtMethod)m).getReturnType().getName() +"\""; // ��{�^�̏ꍇ�AgetClass()�ł��Ȃ����� returnedObject = "$_"; thisClass = "$0.getClass().getName()"; thisObject = "System.identityHashCode($0)";