private static void addDefaultEqualsMethod ( ClassWriter cw , String implClassName ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) Tr . debug ( tc , INDENT + "adding method : equals (Ljava/lang/Object;)Z" ) ; // ----------------------------------------------------------------------- // public boolean equals(Object other) // { // ----------------------------------------------------------------------- final String desc = "(Ljava/lang/Object;)Z" ; MethodVisitor mv = cw . visitMethod ( ACC_PUBLIC , "equals" , desc , null , null ) ; GeneratorAdapter mg = new GeneratorAdapter ( mv , ACC_PUBLIC , "equals" , desc ) ; mg . visitCode ( ) ; // ----------------------------------------------------------------------- // return this == other; // ----------------------------------------------------------------------- mg . loadThis ( ) ; mg . loadArg ( 0 ) ; Label not_equal = new Label ( ) ; mv . visitJumpInsn ( IF_ACMPNE , not_equal ) ; mg . visitInsn ( ICONST_1 ) ; mg . returnValue ( ) ; mg . visitLabel ( not_equal ) ; mg . visitInsn ( ICONST_0 ) ; mg . returnValue ( ) ; // ----------------------------------------------------------------------- // } // ----------------------------------------------------------------------- mg . endMethod ( ) ; mg . visitEnd ( ) ; }
Adds the default definition for the Object . equals method .