[jboss-svn-commits] JBL Code SVN: r14320 - in labs/jbossrules/trunk: drools-core/src/main/java/org/drools/base and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 16 14:13:52 EDT 2007
Author: tirelli
Date: 2007-08-16 14:13:52 -0400 (Thu, 16 Aug 2007)
New Revision: 14320
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java
Log:
JBRULES-1079: fixing shadow proxy equals method issue
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2007-08-16 17:58:45 UTC (rev 14319)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2007-08-16 18:13:52 UTC (rev 14320)
@@ -671,15 +671,15 @@
SpecialString second42 = new SpecialString( "42" );
SpecialString world = new SpecialString( "World" );
- System.out.println( "Inserting ..." );
+ //System.out.println( "Inserting ..." );
session.insert( world );
session.insert( first42 );
session.insert( second42 );
- System.out.println( "Done." );
+ //System.out.println( "Done." );
- System.out.println( "Firing rules ..." );
+ //System.out.println( "Firing rules ..." );
// check all lists are empty
assertTrue( list1.isEmpty() );
@@ -689,16 +689,14 @@
session.fireAllRules();
- System.out.println( "Done." );
+ //System.out.println( "Done." );
// check first list is populated correctly
- assertEquals( 2,
+ assertEquals( 0,
list1.size() );
- assertTrue( list1.contains( first42 ) );
- assertTrue( list1.contains( second42 ) );
// check second list is populated correctly
- assertEquals( 1,
+ assertEquals( 0,
list2.size() );
// check third list is populated correctly
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java 2007-08-16 17:58:45 UTC (rev 14319)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ShadowProxyFactory.java 2007-08-16 18:13:52 UTC (rev 14320)
@@ -1156,200 +1156,200 @@
mv.visitVarInsn( Opcodes.ASTORE,
2 );
- // for each field:
- int count = 0;
- for ( final Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
- final Map.Entry entry = (Map.Entry) it.next();
- final String fieldName = (String) entry.getKey();
- final Method method = (Method) entry.getValue();
- final Class fieldType = method.getReturnType();
- final String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
- count++;
- final Label goNext = new Label();
-
- // if ( ! _fieldIsSet ) {
- final Label l5 = new Label();
- mv.visitLabel( l5 );
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitFieldInsn( Opcodes.GETFIELD,
- className,
- fieldFlag,
- Type.BOOLEAN_TYPE.getDescriptor() );
- final Label l6 = new Label();
- mv.visitJumpInsn( Opcodes.IFNE,
- l6 );
-
- // __field = this.delegate.method();
- final Label l7 = new Label();
- mv.visitLabel( l7 );
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitFieldInsn( Opcodes.GETFIELD,
- className,
- ShadowProxyFactory.DELEGATE_FIELD_NAME,
- Type.getDescriptor( clazz ) );
- if ( clazz.isInterface() ) {
- mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- } else {
- mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- }
- mv.visitFieldInsn( Opcodes.PUTFIELD,
- className,
- fieldName,
- Type.getDescriptor( fieldType ) );
-
- // __fieldIsSet = true;
- final Label l8 = new Label();
- mv.visitLabel( l8 );
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitInsn( Opcodes.ICONST_1 );
- mv.visitFieldInsn( Opcodes.PUTFIELD,
- className,
- fieldFlag,
- Type.BOOLEAN_TYPE.getDescriptor() );
-
- // }
- mv.visitLabel( l6 );
- if ( fieldType.isPrimitive() ) {
- // for primitive types
- // if ( this.field != other.field )
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitFieldInsn( Opcodes.GETFIELD,
- className,
- fieldName,
- Type.getDescriptor( fieldType ) );
- mv.visitVarInsn( Opcodes.ALOAD,
- 2 );
- if ( clazz.isInterface() ) {
- mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- } else {
- mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- }
-
- if ( fieldType.equals( Long.TYPE ) ) {
- mv.visitInsn( Opcodes.LCMP );
- mv.visitJumpInsn( Opcodes.IFEQ,
- goNext );
- } else if ( fieldType.equals( Double.TYPE ) ) {
- mv.visitInsn( Opcodes.DCMPL );
- mv.visitJumpInsn( Opcodes.IFEQ,
- goNext );
- } else if ( fieldType.equals( Float.TYPE ) ) {
- mv.visitInsn( Opcodes.FCMPL );
- mv.visitJumpInsn( Opcodes.IFEQ,
- goNext );
- } else {
- mv.visitJumpInsn( Opcodes.IF_ICMPEQ,
- goNext );
- }
- // return false;
- mv.visitInsn( Opcodes.ICONST_0 );
- mv.visitInsn( Opcodes.IRETURN );
- } else {
- // for non primitive types
- // if( ( ( this.field == null ) && ( other.field != null ) ) ||
- // ( ( this.field != null ) && ( ! this.field.equals( other.field ) ) ) )
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitFieldInsn( Opcodes.GETFIELD,
- className,
- fieldName,
- Type.getDescriptor( fieldType ) );
- final Label secondIfPart = new Label();
- mv.visitJumpInsn( Opcodes.IFNONNULL,
- secondIfPart );
- mv.visitVarInsn( Opcodes.ALOAD,
- 2 );
- if ( clazz.isInterface() ) {
- mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- } else {
- mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- }
- final Label returnFalse = new Label();
- mv.visitJumpInsn( Opcodes.IFNONNULL,
- returnFalse );
- mv.visitLabel( secondIfPart );
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitFieldInsn( Opcodes.GETFIELD,
- className,
- fieldName,
- Type.getDescriptor( fieldType ) );
- mv.visitJumpInsn( Opcodes.IFNULL,
- goNext );
- mv.visitVarInsn( Opcodes.ALOAD,
- 0 );
- mv.visitFieldInsn( Opcodes.GETFIELD,
- className,
- fieldName,
- Type.getDescriptor( fieldType ) );
- mv.visitVarInsn( Opcodes.ALOAD,
- 2 );
- if ( clazz.isInterface() ) {
- mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- } else {
- mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
- Type.getInternalName( clazz ),
- method.getName(),
- Type.getMethodDescriptor( method ) );
- }
- if ( fieldType.isInterface() ) {
- mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
- Type.getInternalName( fieldType ),
- "equals",
- Type.getMethodDescriptor( Type.BOOLEAN_TYPE,
- new Type[]{Type.getType( Object.class )} ) );
- } else {
- mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
- Type.getInternalName( fieldType ),
- "equals",
- Type.getMethodDescriptor( Type.BOOLEAN_TYPE,
- new Type[]{Type.getType( Object.class )} ) );
- }
- mv.visitJumpInsn( Opcodes.IFNE,
- goNext );
- // return false;
- mv.visitLabel( returnFalse );
- mv.visitInsn( Opcodes.ICONST_0 );
- mv.visitInsn( Opcodes.IRETURN );
- }
- mv.visitLabel( goNext );
- }
- // if all fields were ok
- if ( count > 0 ) {
- // return true;
- mv.visitInsn( Opcodes.ICONST_1 );
- // if no fields exists
- } else {
- // return false;
+// // for each field:
+// int count = 0;
+// for ( final Iterator it = fieldTypes.entrySet().iterator(); it.hasNext(); ) {
+// final Map.Entry entry = (Map.Entry) it.next();
+// final String fieldName = (String) entry.getKey();
+// final Method method = (Method) entry.getValue();
+// final Class fieldType = method.getReturnType();
+// final String fieldFlag = fieldName + ShadowProxyFactory.FIELD_SET_FLAG;
+// count++;
+// final Label goNext = new Label();
+//
+// // if ( ! _fieldIsSet ) {
+// final Label l5 = new Label();
+// mv.visitLabel( l5 );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitFieldInsn( Opcodes.GETFIELD,
+// className,
+// fieldFlag,
+// Type.BOOLEAN_TYPE.getDescriptor() );
+// final Label l6 = new Label();
+// mv.visitJumpInsn( Opcodes.IFNE,
+// l6 );
+//
+// // __field = this.delegate.method();
+// final Label l7 = new Label();
+// mv.visitLabel( l7 );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitFieldInsn( Opcodes.GETFIELD,
+// className,
+// ShadowProxyFactory.DELEGATE_FIELD_NAME,
+// Type.getDescriptor( clazz ) );
+// if ( clazz.isInterface() ) {
+// mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// } else {
+// mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// }
+// mv.visitFieldInsn( Opcodes.PUTFIELD,
+// className,
+// fieldName,
+// Type.getDescriptor( fieldType ) );
+//
+// // __fieldIsSet = true;
+// final Label l8 = new Label();
+// mv.visitLabel( l8 );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitInsn( Opcodes.ICONST_1 );
+// mv.visitFieldInsn( Opcodes.PUTFIELD,
+// className,
+// fieldFlag,
+// Type.BOOLEAN_TYPE.getDescriptor() );
+//
+// // }
+// mv.visitLabel( l6 );
+// if ( fieldType.isPrimitive() ) {
+// // for primitive types
+// // if ( this.field != other.field )
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitFieldInsn( Opcodes.GETFIELD,
+// className,
+// fieldName,
+// Type.getDescriptor( fieldType ) );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 2 );
+// if ( clazz.isInterface() ) {
+// mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// } else {
+// mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// }
+//
+// if ( fieldType.equals( Long.TYPE ) ) {
+// mv.visitInsn( Opcodes.LCMP );
+// mv.visitJumpInsn( Opcodes.IFEQ,
+// goNext );
+// } else if ( fieldType.equals( Double.TYPE ) ) {
+// mv.visitInsn( Opcodes.DCMPL );
+// mv.visitJumpInsn( Opcodes.IFEQ,
+// goNext );
+// } else if ( fieldType.equals( Float.TYPE ) ) {
+// mv.visitInsn( Opcodes.FCMPL );
+// mv.visitJumpInsn( Opcodes.IFEQ,
+// goNext );
+// } else {
+// mv.visitJumpInsn( Opcodes.IF_ICMPEQ,
+// goNext );
+// }
+// // return false;
+// mv.visitInsn( Opcodes.ICONST_0 );
+// mv.visitInsn( Opcodes.IRETURN );
+// } else {
+// // for non primitive types
+// // if( ( ( this.field == null ) && ( other.field != null ) ) ||
+// // ( ( this.field != null ) && ( ! this.field.equals( other.field ) ) ) )
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitFieldInsn( Opcodes.GETFIELD,
+// className,
+// fieldName,
+// Type.getDescriptor( fieldType ) );
+// final Label secondIfPart = new Label();
+// mv.visitJumpInsn( Opcodes.IFNONNULL,
+// secondIfPart );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 2 );
+// if ( clazz.isInterface() ) {
+// mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// } else {
+// mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// }
+// final Label returnFalse = new Label();
+// mv.visitJumpInsn( Opcodes.IFNONNULL,
+// returnFalse );
+// mv.visitLabel( secondIfPart );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitFieldInsn( Opcodes.GETFIELD,
+// className,
+// fieldName,
+// Type.getDescriptor( fieldType ) );
+// mv.visitJumpInsn( Opcodes.IFNULL,
+// goNext );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 0 );
+// mv.visitFieldInsn( Opcodes.GETFIELD,
+// className,
+// fieldName,
+// Type.getDescriptor( fieldType ) );
+// mv.visitVarInsn( Opcodes.ALOAD,
+// 2 );
+// if ( clazz.isInterface() ) {
+// mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// } else {
+// mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+// Type.getInternalName( clazz ),
+// method.getName(),
+// Type.getMethodDescriptor( method ) );
+// }
+// if ( fieldType.isInterface() ) {
+// mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
+// Type.getInternalName( fieldType ),
+// "equals",
+// Type.getMethodDescriptor( Type.BOOLEAN_TYPE,
+// new Type[]{Type.getType( Object.class )} ) );
+// } else {
+// mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
+// Type.getInternalName( fieldType ),
+// "equals",
+// Type.getMethodDescriptor( Type.BOOLEAN_TYPE,
+// new Type[]{Type.getType( Object.class )} ) );
+// }
+// mv.visitJumpInsn( Opcodes.IFNE,
+// goNext );
+// // return false;
+// mv.visitLabel( returnFalse );
+// mv.visitInsn( Opcodes.ICONST_0 );
+// mv.visitInsn( Opcodes.IRETURN );
+// }
+// mv.visitLabel( goNext );
+// }
+// // if all fields were ok
+// if ( count > 0 ) {
+// // return true;
+// mv.visitInsn( Opcodes.ICONST_1 );
+// // if no fields exists
+// } else {
+// // return false;
mv.visitInsn( Opcodes.ICONST_0 );
- }
+// }
mv.visitInsn( Opcodes.IRETURN );
final Label lastLabel = new Label();
mv.visitLabel( lastLabel );
More information about the jboss-svn-commits
mailing list