Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1639

Can not do a "new SomeClass()" in a default argument...

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-RC-2
    • 1.1-rc-3
    • None
    • None
    • Groovy 1.0RC2

    Description

      BUG! exception in phase 'class generation' in source unit '/mnt/hda7/home/uwh1/workspace/GMan/src/bmodel/BObjectProperty.groovy' ClassNode#getTypeClass for PropertyType is called before the type class is set
      at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:950)
      at org.codehaus.groovy.classgen.BytecodeHelper.getClassInternalName(BytecodeHelper.java:157)
      at org.codehaus.groovy.classgen.AsmClassGenerator.makeFieldClassName(AsmClassGenerator.java:1844)
      at org.codehaus.groovy.classgen.AsmClassGenerator.getStaticFieldName(AsmClassGenerator.java:1866)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitClassExpression(AsmClassGenerator.java:2329)
      at org.codehaus.groovy.ast.expr.ClassExpression.visit(ClassExpression.java:65)
      at org.codehaus.groovy.classgen.AsmClassGenerator.makeCall(AsmClassGenerator.java:1581)
      at org.codehaus.groovy.classgen.AsmClassGenerator.makeCall(AsmClassGenerator.java:1562)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorCallExpression(AsmClassGenerator.java:1836)
      at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:74)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:3009)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitTupleExpression(AsmClassGenerator.java:2426)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitArgumentlistExpression(AsmClassGenerator.java:2407)
      at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:91)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitSpecialConstructorCall(AsmClassGenerator.java:1711)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorCallExpression(AsmClassGenerator.java:1822)
      at org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:74)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitAndAutoboxBoolean(AsmClassGenerator.java:3009)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:1113)
      at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:70)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:49)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:54)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:506)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:58)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructor(AsmClassGenerator.java:537)
      at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:833)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:36)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:330)
      at org.codehaus.groovy.control.CompilationUnit$9.call(CompilationUnit.java:746)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:932)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:478)
      at org.codehaus.groovy.eclipse.model.GroovyProject.compileGroovyFiles(GroovyProject.java:332)
      at org.codehaus.groovy.eclipse.model.GroovyProject.buildGroovyContent(GroovyProject.java:211)
      at org.codehaus.groovy.eclipse.model.GroovyProject.buildGroovyContent(GroovyProject.java:167)
      at org.codehaus.groovy.eclipse.model.GroovyModel.buildGroovyContent(GroovyModel.java:115)
      at org.codehaus.groovy.eclipse.builder.GroovyBuilder.build(GroovyBuilder.java:59)
      at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:603)
      at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
      at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:167)
      at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
      at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:230)
      at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
      at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:233)
      at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:252)
      at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:285)
      at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145)
      at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:208)
      at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

      Here is my Code:

          File BObjectProperty.groovy:
          package bmodel;
          class BObjectProperty extends MultipleInheritanceObject{
                  def props = [:]; // all properties are in here
                  def oldProps = [:]; // if the user changed something, here are the old values stored
                  def changed = false // true if props and oldProps are different
                   BObjectProperty(BObject bObject, String name, PropertyType type = new PropertyType("BIGINT"), modifyable = false) {
                          super(bObject)
                          props.name = name
                          props.bObject = bObject
                          props.type = type
                          props.modifyable = true
                  }
                  def getName() {return props.name}
                  def setName(name) {props.name = name}
                  //def setModifyable(bool) {props.modifyable = bool} There is no way to change this after Init :-) OK, there remains the way over the props directly
                  def getModifyable(){return props.modifyable}
                  def getType() {props.type}
                  def setType(type) {
                          // typecheck for a valid type
                          if (getDBValidTypes().contains(type)) props.type = type
                  }
                  def getVisual(name, modifyable = false) {
                          if (!props.modifyable || !modifyable) return new javax.swing.JLabel(props.type.toString())
                          // create new graphical helper which keeps the props.type in sync with the graphical representation
                  }
          }
      
      
          File MultipleInheritanceObject.groovy:
          package bmodel;
      
      
          class MultipleInheritanceObject {
                  def mixon = [];
                  def parentObj = null
                  MultipleInheritanceObject(parent) {
                          parentObj = parent
                  }
      
                  def invokeMethod(String name, Object args) {
                          def done = false
                          if (str =~ /^...DB*/) {
                                  return parentObj."$name"(*args)
                          }
                          mixon.each{obj ->
                                  try {
                                          if (!done) {
                                                  def ret =  obj."$name"(*args)
                                                  done = true
                                                  return ret
                                          }
                                  } catch (mme) {
                                          println "Method $name does not exist in Class ${this.class}!"
                                          println mme
                                  }
                          }
                  }
      
          }
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            uwe.hartl@gmx.net Uwe Hartl
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: