<commit_before>package com.asakusafw.spark.tools.asm

import java.io.PrintWriter
import java.io.StringWriter
import java.util.Arrays

import scala.collection.mutable

import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.ClassWriter
import org.objectweb.asm.Opcodes._
import org.objectweb.asm.Type
import org.objectweb.asm.util.TraceClassVisitor
import org.slf4j.LoggerFactory

abstract class ClassBuilder(val thisType: Type, val signature: Option[String], val superType: Type, val interfaceTypes: Type*) {

  val logger = LoggerFactory.getLogger(getClass)

  def this(thisType: Type, signature: String, superType: Type, interfaceTypes: Type*) =
    this(thisType, Option(signature), superType, interfaceTypes: _*)

  def this(thisType: Type, superType: Type, interfaceTypes: Type*) =
    this(thisType, None, superType, interfaceTypes: _*)

  final def build(): Array[Byte] = {
    val cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES)
    cw.visit(
      V1_7,
      ACC_PUBLIC,
      thisType.getInternalName(),
      signature.orNull,
      superType.getInternalName(),
      interfaceTypes.map(_.getInternalName()).toArray)
    defAnnotations(new AnnotationDef(cw))
    defFields(new FieldDef(cw))
    defConstructors(new ConstructorDef(cw))
    val methodDef = new MethodDef(cw)
    defMethods(methodDef)
    if (definingToString) {
      defToString0(methodDef)
    }
    if (definingHashCode) {
      defHashCode0(methodDef)
    }
    if (definingEquals) {
      defEquals0(methodDef)
    }
    cw.visitEnd()
    val bytes = cw.toByteArray()
    if (logger.isDebugEnabled) {
      logger.debug {
        val writer = new StringWriter
        val cr = new ClassReader(bytes)
        cr.accept(new TraceClassVisitor(new PrintWriter(writer)), 0)
        writer.toString
      }
    }
    bytes
  }

  def defAnnotations(annotationDef: AnnotationDef): Unit = {
  }<commit_msg>Change log level for class builder to trace level.<commit_after>package com.asakusafw.spark.tools.asm

import java.io.PrintWriter
import java.io.StringWriter
import java.util.Arrays

import scala.collection.mutable

import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.ClassWriter
import org.objectweb.asm.Opcodes._
import org.objectweb.asm.Type
import org.objectweb.asm.util.TraceClassVisitor
import org.slf4j.LoggerFactory

abstract class ClassBuilder(val thisType: Type, val signature: Option[String], val superType: Type, val interfaceTypes: Type*) {

  val logger = LoggerFactory.getLogger(getClass)

  def this(thisType: Type, signature: String, superType: Type, interfaceTypes: Type*) =
    this(thisType, Option(signature), superType, interfaceTypes: _*)

  def this(thisType: Type, superType: Type, interfaceTypes: Type*) =
    this(thisType, None, superType, interfaceTypes: _*)

  final def build(): Array[Byte] = {
    val cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES)
    cw.visit(
      V1_7,
      ACC_PUBLIC,
      thisType.getInternalName(),
      signature.orNull,
      superType.getInternalName(),
      interfaceTypes.map(_.getInternalName()).toArray)
    defAnnotations(new AnnotationDef(cw))
    defFields(new FieldDef(cw))
    defConstructors(new ConstructorDef(cw))
    val methodDef = new MethodDef(cw)
    defMethods(methodDef)
    if (definingToString) {
      defToString0(methodDef)
    }
    if (definingHashCode) {
      defHashCode0(methodDef)
    }
    if (definingEquals) {
      defEquals0(methodDef)
    }
    cw.visitEnd()
    val bytes = cw.toByteArray()
    if (logger.isTraceEnabled) {
      logger.trace {
        val writer = new StringWriter
        val cr = new ClassReader(bytes)
        cr.accept(new TraceClassVisitor(new PrintWriter(writer)), 0)
        writer.toString
      }
    }
    bytes
  }

  def defAnnotations(annotationDef: AnnotationDef): Unit = {
  }
{'fraction_non_alphanumeric': 0.09972088302461304, 'fraction_numerical': 0.003552397868561279, 'mean_word_length': 3.8190709046454767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5630771', 'n_tokens_mistral': 1235, 'n_tokens_neox': 1225, 'n_words': 260}