Creates a default constructor for the class

@param cw
430729
protected void buildDefaultConstructor(ClassVisitor cw,
                                           ClassDefinition classDef) {


        MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
                "<init>",
                Type.getMethodDescriptor( Type.VOID_TYPE,
                        new Type[]{} ),
                null,
                null );
        mv.visitCode();

        Label l0 = null;
        if ( this.debug ) {
            l0 = new Label();
            mv.visitLabel( l0 );
        }

        boolean hasObjects = defaultConstructorStart( mv, classDef );

        mv.visitInsn(Opcodes.RETURN);
        Label l1 = null;
        if ( this.debug ) {
            l1 = new Label();
            mv.visitLabel( l1 );
            mv.visitLocalVariable( "this",
                                   BuildUtils.getTypeDescriptor( classDef.getClassName() ),
                                   null,
                                   l0,
                                   l1,
                                   0 );
        }
        mv.visitMaxs( 0, 0 );
        mv.visitEnd();

    }
728530
public Constructor<?> getDefaultConstructorForFieldType(final Type fieldTypeFullyResolved,
            final ClassFieldCache classFieldCache) {
        if (!isTypeVariable) {
            return defaultConstructorForFieldType;
        } else {
            final Class<?> fieldRawTypeFullyResolved = JSONUtils.getRawType(fieldTypeFullyResolved);
            return classFieldCache.getDefaultConstructorForConcreteTypeOf(fieldRawTypeFullyResolved);
        }
    }
1064827
private static Constructor<?> findConstructorForInnerClass(final Class<?> klazz, final Class<?> declaringClass) {
    final Constructor<?>[] constructors = klazz.getDeclaredConstructors();
    if (constructors.length == 1) {
      return constructors[0];
    }
    for (final Constructor<?> c : constructors) {
      final Class<?>[] params = c.getParameterTypes();
      if (params.length == 1 && params[0] == declaringClass) {
        return c;
      }
    }
    return constructors[0];
  }
515317
private static Constructor<?> getConstructor(final Class<?> genericClass, final Class<?>[] constructorParameterTypes) {
        Constructor<?> constructor = null;
        try {
            constructor = genericClass.getConstructor(constructorParameterTypes);
        } catch (final NoSuchMethodException e) {
            // Return the first constructor as a workaround
            constructor = genericClass.getConstructors()[0];
        } catch (final SecurityException e) {
            LOGGER.log(NO_CONSTRUCTOR, e);
            throw e; // Pop up the exception to let it managed by the caller method
        }
        return constructor;
    }
265888
public static Writable newInstance(Class<? extends Writable> c,
      Configuration conf, boolean supportJobConf) {
    WritableFactory factory = WritableFactories.getFactory(c);
    if (factory != null) {
      Writable result = factory.newInstance();
      if (result instanceof Configurable) {
        ((Configurable) result).setConf(conf);
      }
      return result;
    } else {
      return ReflectionUtils.newInstance(c, conf, supportJobConf);
    }
  }
170194
public static <T> T callConstructor(Class<T> c, Class<?>[] argTypes, Object[] args) {
        try {
            Constructor<T> cons = c.getConstructor(argTypes);
            return cons.newInstance(args);
        } catch(InvocationTargetException e) {
            throw getCause(e);
        } catch(IllegalAccessException e) {
            throw new IllegalStateException(e);
        } catch(NoSuchMethodException e) {
            throw new IllegalArgumentException(e);
        } catch(InstantiationException e) {
            throw new IllegalArgumentException(e);
        }
    }
772304
private synchronized void defaultInit() 
    {
        if (!_initialized)
        {
            _initialized = true;
            String sinkClasses = System.getProperty("LOG_SINKS","org.browsermob.proxy.jetty.log.OutputStreamLogSink");
            StringTokenizer sinkTokens = new StringTokenizer(sinkClasses, ";, ");
                    
            LogSink sink= null;
            while (sinkTokens.hasMoreTokens())
            {
                String sinkClassName = sinkTokens.nextToken();
                    	
                try
                {
                    Class sinkClass = Loader.loadClass(this.getClass(),sinkClassName);
                    if (org.browsermob.proxy.jetty.log.LogSink.class.isAssignableFrom(sinkClass)) {
                        sink = (LogSink)sinkClass.newInstance();
                        sink.start();
                        add(sink);
                    }
                    else
                        // Can't use Code.fail here, that's what we're setting up
                        System.err.println(sinkClass+" is not a org.browsermob.proxy.jetty.log.LogSink");
                }
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
986570
public static void generateJLCGDMS(ClassWriter cw, String classname, String field, String methodname) {
		FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, field, "Ljava/lang/reflect/Method;", null, null);
		fv.visitEnd();

		MethodVisitor mv = cw.visitMethod(ACC_PRIVATE + ACC_STATIC, field,
				"(Ljava/lang/Class;)[Ljava/lang/reflect/Method;", null,
				null);
		mv.visitCode();
		Label l0 = new Label();
		Label l1 = new Label();
		Label l2 = new Label();
		mv.visitTryCatchBlock(l0, l1, l2, "java/lang/Exception");
		Label l3 = new Label();
		mv.visitLabel(l3);
		mv.visitFieldInsn(GETSTATIC, classname, field, "Ljava/lang/reflect/Method;");
		mv.visitJumpInsn(IFNONNULL, l0);
		Label l4 = new Label();
		mv.visitLabel(l4);
		mv.visitVarInsn(ALOAD, 0);
		mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", methodname, "()[Ljava/lang/reflect/Method;", false);
		mv.visitInsn(ARETURN);
		mv.visitLabel(l0);
		mv.visitFieldInsn(GETSTATIC, classname, field, "Ljava/lang/reflect/Method;");
		mv.visitInsn(ACONST_NULL);
		mv.visitInsn(ICONST_1);
		mv.visitTypeInsn(ANEWARRAY, "java/lang/Object");
		mv.visitInsn(DUP);
		mv.visitInsn(ICONST_0);
		mv.visitVarInsn(ALOAD, 0);
		mv.visitInsn(AASTORE);
		mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/reflect/Method", "invoke",
				"(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;", false);
		mv.visitTypeInsn(CHECKCAST, "[Ljava/lang/reflect/Method;");
		mv.visitLabel(l1);
		mv.visitInsn(ARETURN);
		mv.visitLabel(l2);
		mv.visitVarInsn(ASTORE, 1);
		Label l5 = new Label();
		mv.visitLabel(l5);
		mv.visitInsn(ACONST_NULL);
		mv.visitInsn(ARETURN);
		Label l6 = new Label();
		mv.visitLabel(l6);
		//		mv.visitLocalVariable("clazz", "Ljava/lang/Class;", "Ljava/lang/Class<*>;", l3, l6, 0);
		//		mv.visitLocalVariable("e", "Ljava/lang/Exception;", null, l5, l6, 1);
		mv.visitMaxs(6, 2);
		mv.visitEnd();
	}
884878
public static final <T> T defaultFactory(Class<T> cls, String hint)
    {
        try
        {
            return cls.newInstance();
        }
        catch (InstantiationException | IllegalAccessException ex)
        {
            throw new IllegalArgumentException(ex);
        }
    }
1155426
void writeConstructor(Definition def, Writer out, int indent) throws IOException
   {
      writeSimpleMethodSignature(out, indent, " * Default constructor", "public " + getClassName(def) + "()");
      writeLeftCurlyBracket(out, indent);

      writeWithIndent(out, indent + 1, "this.mbeanServer = null;\n");
      writeWithIndent(out, indent + 1, "this.objectName = \"" + def.getDefaultValue() + ",class=HelloWorld\";\n");
      writeWithIndent(out, indent + 1, "this.registered = false;\n\n");

      writeRightCurlyBracket(out, indent);
      writeEol(out);
   }
808926
private E createUsingConstructor() throws CheckedAnalysisException {
        Constructor<E> constructor;
        try {
            constructor = databaseClass.getConstructor(new Class[0]);
        } catch (NoSuchMethodException e) {
            return null;
        }

        try {
            return constructor.newInstance(new Object[0]);
        } catch (InstantiationException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        } catch (IllegalAccessException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        } catch (InvocationTargetException e) {
            throw new CheckedAnalysisException("Could not create " + databaseClass.getName(), e);
        }
    }
927942
private void defineConstructor()
    {
        //
        // declare the constructor
        MethodDefinition constructor = new MethodDefinition(
                a(PUBLIC),
                "<init>",
                type(void.class),
                parameters.getParameters()
        );

        // invoke super (Object) constructor
        constructor.loadThis().invokeConstructor(type(Object.class));

        // this.foo = foo;
        for (FieldDefinition fieldDefinition : parameters.getFields()) {
            constructor.loadThis()
                    .loadVariable(fieldDefinition.getName())
                    .putField(codecType, fieldDefinition);
        }

        // return; (implicit)
        constructor.ret();

        classDefinition.addMethod(constructor);
    }
89712
@SuppressWarnings("unchecked")
   private Handler createHandler() throws Throwable
   {
      Class clz = handler;

      while (clz != Object.class)
      {
         try
         {
            Constructor c = clz.getDeclaredConstructor((Class[])null);
            c.setAccessible(true);

            return (Handler)c.newInstance((Object[])null);
         }
         catch (Throwable t)
         {
            t.printStackTrace(System.err);
         }

         clz = clz.getSuperclass();
      }

      throw new IllegalStateException("Unable to find default constructor");
   }
390303
public ConstructorFilterBuilder isDefault() {
        add(new NegationConstructorFilter(new ModifierConstructorFilter(Modifier.PUBLIC & Modifier.PROTECTED & Modifier.PRIVATE)));
        return this;
    }
315631
protected static void buildGetMethod(final Class< ? > originalClass,
                                         final String className,
                                         final Class< ? > superClass,
                                         final Method getterMethod,
                                         final ClassWriter cw) {

        final Class< ? > fieldType = getterMethod.getReturnType();
        Method overridingMethod;
        try {
            overridingMethod = superClass.getMethod( getOverridingGetMethodName( fieldType ),
                                                     InternalWorkingMemory.class, Object.class );
        } catch ( final Exception e ) {
            throw new RuntimeException( "This is a bug. Please report back to JBoss Rules team.",
                                        e );
        }
        final MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
                                                 overridingMethod.getName(),
                                                 Type.getMethodDescriptor( overridingMethod ),
                                                 null,
                                                 null );

        mv.visitCode();

        final Label l0 = new Label();
        mv.visitLabel( l0 );
        mv.visitVarInsn( Opcodes.ALOAD,
                         2 );
        mv.visitTypeInsn( Opcodes.CHECKCAST,
                          Type.getInternalName( originalClass ) );

        if ( originalClass.isInterface() ) {
            mv.visitMethodInsn( Opcodes.INVOKEINTERFACE,
                                Type.getInternalName( originalClass ),
                                getterMethod.getName(),
                                Type.getMethodDescriptor( getterMethod ) );
        } else {
            mv.visitMethodInsn( Opcodes.INVOKEVIRTUAL,
                                Type.getInternalName( originalClass ),
                                getterMethod.getName(),
                                Type.getMethodDescriptor( getterMethod ) );
        }
        mv.visitInsn( Type.getType( fieldType ).getOpcode( Opcodes.IRETURN ) );
        final Label l1 = new Label();
        mv.visitLabel( l1 );
        mv.visitLocalVariable( "this",
                               "L" + className + ";",
                               null,
                               l0,
                               l1,
                               0 );
        mv.visitLocalVariable( "workingMemory",
                               Type.getDescriptor( InternalWorkingMemory.class ),
                               null,
                               l0,
                               l1,
                               1 );
        mv.visitLocalVariable( "object",
                               Type.getDescriptor( Object.class ),
                               null,
                               l0,
                               l1,
                               2 );
        mv.visitMaxs( 0,
                      0 );
        mv.visitEnd();
    }
442594
protected void generateDefaultConstructor(SourceWriter sourceWriter, String simpleName) {

    generateSourcePublicConstructorDeclaration(sourceWriter, simpleName);
    sourceWriter.println("super();");
    generateSourceCloseBlock(sourceWriter);
  }
684435
private static void addDefaultHashCodeMethod(ClassWriter cw, String implClassName)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, INDENT + "adding method : hashCode ()I");

        // -----------------------------------------------------------------------
        // public int hashCode()
        // {
        // -----------------------------------------------------------------------
        final String desc = "()I";
        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "hashCode", desc, null, null);
        GeneratorAdapter mg = new GeneratorAdapter(mv, ACC_PUBLIC, "hashCode", desc);
        mg.visitCode();

        // -----------------------------------------------------------------------
        //    return System.identityHashCode(this);
        // -----------------------------------------------------------------------
        mg.loadThis();
        mg.visitMethodInsn(INVOKESTATIC, "java/lang/System", "identityHashCode", "(Ljava/lang/Object;)I");
        mg.returnValue();

        // -----------------------------------------------------------------------
        // }
        // -----------------------------------------------------------------------
        mg.endMethod();
        mg.visitEnd();
    }