You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by ol...@apache.org on 2015/02/05 04:36:47 UTC

svn commit: r1657469 - in /incubator/sirona/trunk/agent/javaagent/src: main/java/org/apache/sirona/javaagent/ test/java/org/apache/sirona/javaagent/listener/ test/java/org/apache/test/sirona/javaagent/

Author: olamy
Date: Thu Feb  5 03:36:47 2015
New Revision: 1657469

URL: http://svn.apache.org/r1657469
Log:
primitive must be box up to the corresponding Object instance

Modified:
    incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaClassVisitor.java
    incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/javaagent/listener/PathTrackingListenerTest.java
    incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/test/sirona/javaagent/App.java

Modified: incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaClassVisitor.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaClassVisitor.java?rev=1657469&r1=1657468&r2=1657469&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaClassVisitor.java (original)
+++ incubator/sirona/trunk/agent/javaagent/src/main/java/org/apache/sirona/javaagent/SironaClassVisitor.java Thu Feb  5 03:36:47 2015
@@ -154,12 +154,87 @@ public class SironaClassVisitor extends
             // stores the arguments in the array
             for ( int i = 0; i < length; i++ )
             {
+                Type tp = Type.getArgumentTypes( desc )[i];
+
                 // duplicates the reference to the array. AASTORE consumes the stack element with the reference to the array.
                 super.visitInsn( DUP );
                 // could be optimized
                 super.visitIntInsn( BIPUSH, i );
                 // puts the value of the current argument on the stack
-                super.visitVarInsn( ALOAD, i + ( isStatic ? 0 : 1 ) );
+                //super.visitVarInsn( ALOAD, i + ( isStatic ? 0 : 1 ) );
+
+                // arguments can be primitive so we must box up to the corresponding Object
+                if ( tp.equals( Type.BOOLEAN_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.ILOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Boolean", //
+                                           "valueOf", //
+                                           "(Z)Ljava/lang/Boolean;" );
+                }
+                else if ( tp.equals( Type.BYTE_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.ILOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Byte", //
+                                           "valueOf", //
+                                           "(B)Ljava/lang/Byte;" );
+                }
+                else if ( tp.equals( Type.CHAR_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.ILOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Character", //
+                                           "valueOf", //
+                                           "(C)Ljava/lang/Character;" );
+                }
+                else if ( tp.equals( Type.SHORT_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.ILOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Short", //
+                                           "valueOf", //
+                                           "(S)Ljava/lang/Short;" );
+                }
+                else if ( tp.equals( Type.INT_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.ILOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Integer", //
+                                           "valueOf", //
+                                           "(I)Ljava/lang/Integer;" );
+                }
+                else if ( tp.equals( Type.LONG_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.LLOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Long", //
+                                           "valueOf", //
+                                           "(J)Ljava/lang/Long;" );
+                    i++;
+                }
+                else if ( tp.equals( Type.FLOAT_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.FLOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Float", //
+                                           "valueOf", //
+                                           "(F)Ljava/lang/Float;" );
+                }
+                else if ( tp.equals( Type.DOUBLE_TYPE ) )
+                {
+                    super.visitVarInsn( Opcodes.DLOAD, i + ( isStatic ? 0 : 1 ) );
+                    super.visitMethodInsn( Opcodes.INVOKESTATIC, //
+                                           "java/lang/Double", //
+                                           "valueOf", //
+                                           "(D)Ljava/lang/Double;" );
+
+                }
+                else
+                {
+                    super.visitVarInsn( Opcodes.ALOAD, i );
+                }
+
                 // stores the value of the current argument in the array
                 super.visitInsn( AASTORE );
             }

Modified: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/javaagent/listener/PathTrackingListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/javaagent/listener/PathTrackingListenerTest.java?rev=1657469&r1=1657468&r2=1657469&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/javaagent/listener/PathTrackingListenerTest.java (original)
+++ incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/sirona/javaagent/listener/PathTrackingListenerTest.java Thu Feb  5 03:36:47 2015
@@ -43,7 +43,7 @@ public class PathTrackingListenerTest
 
     @Test
     @AgentArgs(value = "debug=true|sirona.agent.debug=${sirona.agent.debug}",
-               sysProps = "project.build.directory=${project.build.directory}|sirona.agent.debug=${sirona.agent.debug}|org.apache.sirona.configuration.sirona.properties=${project.build.directory}/test-classes/pathtracking/sirona.properties|java.io.tmpdir=${java.io.tmpdir}"
+               sysProps = "project.build.directory=${project.build.directory}|sirona.agent.debug=${sirona.agent.debug}|org.apache.sirona.configuration.sirona.properties=${project.build.directory}/test-classes/pathtracking/sirona.properties|java.io.tmpdir=${project.build.directory}"
                 )
     public void simpleTest()
         throws Exception
@@ -97,7 +97,7 @@ public class PathTrackingListenerTest
 
         entry = entries.get( 2 );
 
-        Assert.assertEquals( "pub(java.lang.String,java.util.List)", entry.getMethodName() );
+        Assert.assertEquals( "pub(java.lang.String,java.util.List,int)", entry.getMethodName() );
 
         Assert.assertEquals( "org.apache.test.sirona.javaagent.App", entry.getClassName() );
 

Modified: incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/test/sirona/javaagent/App.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/test/sirona/javaagent/App.java?rev=1657469&r1=1657468&r2=1657469&view=diff
==============================================================================
--- incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/test/sirona/javaagent/App.java (original)
+++ incubator/sirona/trunk/agent/javaagent/src/test/java/org/apache/test/sirona/javaagent/App.java Thu Feb  5 03:36:47 2015
@@ -37,10 +37,10 @@ public class App
         throws Exception
     {
         this.foo();
-        this.pub( "blabla", Arrays.asList( "Mountain Goat", "Fatyak" ) );
+        this.pub( "blabla", Arrays.asList( "Mountain Goat", "Fatyak" ), 2 );
     }
 
-    public void pub( String foo, List<String> beers )
+    public void pub( String foo, List<String> beers, int i )
         throws Exception
     {
         Thread.sleep( 100 );