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

An error about "org.codehaus.groovy.syntax.SyntaxException: Access to java.lang.Object#pOfferingInstId is forbidden"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4.5
    • None
    • groovy-jdk
    • None
    • java.version=1.8.0_45
      java.runtime.version=1.8.0_45-b15
      os.arch=x86
      os.name=Windows 7
      sun.jnu.encoding=GBK

    Description

      1.We use static compilation and AST conversion to compile scripts.
      The original expression is:
      def bunledSubOfferInstReq = deepClone()
      The converted expression:
      def bunledSubOfferInstReq = (pkg.ViewObject) pkg.FunctionRuntimeTool.invokeFunction(this, deepClone)

      2.The class pkg.ViewObject is implement java.util.Map interface.

      3.When using the ViewObject property in BinaryExpression, it is wrong to put it in an if statement.

      --compile successed
      def bunledSubOfferInstReq = deepClone()
      bunledSubOfferInstReq.pOfferingInstId = bunledSubOfferInstReq.pOfferingInstId

      --compile failed
      if (condition)
      {
      def bunledSubOfferInstReq = deepClone()
      bunledSubOfferInstReq.pOfferingInstId = bunledSubOfferInstReq.pOfferingInstId
      }

      4.I found a phenomenon cause this error, at compile successed situation, the ClassNode of ViewObject has redirect. [toString result-pkg.ViewObject -> pkg.ViewObject]
      At comile failed situation, the ClassNode of ViewObject redirect is null. [toString result-pkg.ViewObject]

      5.The error stacktrace as below:
      org.codehaus.groovy.syntax.SyntaxException: Access to java.lang.Object#pOfferingInstId is forbidden @ line 106, column 43.

      Thread [main] (Suspended (breakpoint at line 91 in ErrorCollector))
      owns: HashMap<K,V> (id=67)
      ErrorCollector.addErrorAndContinue(Message) line: 91
      ErrorCollector.addError(Message) line: 104
      ErrorCollector.addError(Message, boolean) line: 123
      ErrorCollector.addError(SyntaxException, SourceUnit) line: 132
      SourceUnit.addError(SyntaxException) line: 360
      StaticTypesCallSiteWriter.makeGetPropertySite(Expression, String, boolean, boolean) line: 225
      AsmClassGenerator.visitAttributeOrProperty(PropertyExpression, MethodCallerMultiAdapter) line: 965
      AsmClassGenerator.visitPropertyExpression(PropertyExpression) line: 1001
      PropertyExpression.visit(GroovyCodeVisitor) line: 57
      StaticTypesBinaryExpressionMultiTypeDispatcher(BinaryExpressionHelper).evaluateEqual(BinaryExpression, boolean) line: 316
      StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(BinaryExpression, boolean) line: 151
      StaticTypesBinaryExpressionMultiTypeDispatcher(BinaryExpressionHelper).eval(BinaryExpression) line: 84
      AsmClassGenerator.visitBinaryExpression(BinaryExpression) line: 638
      BinaryExpression.visit(GroovyCodeVisitor) line: 51
      StaticTypesStatementWriter(StatementWriter).writeExpressionStatement(ExpressionStatement) line: 607
      AsmClassGenerator.visitExpressionStatement(ExpressionStatement) line: 620
      ExpressionStatement.visit(GroovyCodeVisitor) line: 42
      StaticTypesStatementWriter(StatementWriter).writeBlockStatement(BlockStatement) line: 84
      StaticTypesStatementWriter.writeBlockStatement(BlockStatement) line: 65
      AsmClassGenerator.visitBlockStatement(BlockStatement) line: 566
      BlockStatement.visit(GroovyCodeVisitor) line: 71
      StaticTypesStatementWriter(StatementWriter).writeIfElse(IfStatement) line: 288
      AsmClassGenerator.visitIfElse(IfStatement) line: 582
      IfStatement.visit(GroovyCodeVisitor) line: 43
      StaticTypesStatementWriter(StatementWriter).writeBlockStatement(BlockStatement) line: 84
      StaticTypesStatementWriter.writeBlockStatement(BlockStatement) line: 65
      AsmClassGenerator.visitBlockStatement(BlockStatement) line: 566
      BlockStatement.visit(GroovyCodeVisitor) line: 71
      AsmClassGenerator(ClassCodeVisitorSupport).visitClassCodeContainer(Statement) line: 104
      AsmClassGenerator(ClassCodeVisitorSupport).visitConstructorOrMethod(MethodNode, boolean) line: 115
      AsmClassGenerator.visitStdMethod(MethodNode, boolean, Parameter[], Statement) line: 430
      AsmClassGenerator.visitConstructorOrMethod(MethodNode, boolean) line: 387
      AsmClassGenerator(ClassCodeVisitorSupport).visitMethod(MethodNode) line: 126
      AsmClassGenerator.visitMethod(MethodNode) line: 507
      ClassNode.visitContents(GroovyClassVisitor) line: 1086
      AsmClassGenerator(ClassCodeVisitorSupport).visitClass(ClassNode) line: 53
      AsmClassGenerator.visitClass(ClassNode) line: 233
      CompilationUnit$16.call(SourceUnit, GeneratorContext, ClassNode) line: 813
      CompilationUnit.applyToPrimaryClassNodes(CompilationUnit$PrimaryClassNodeOperation) line: 1055
      CompilationUnit.doPhaseOperation(Object) line: 591
      CompilationUnit.processPhaseOperations(int) line: 569
      CompilationUnit.compile(int) line: 546
      GroovyClassLoader.doParseClass(GroovyCodeSource) line: 298
      GroovyClassLoader.parseClass(GroovyCodeSource, boolean) line: 268
      GroovyShell.parseClass(GroovyCodeSource) line: 694
      GroovyShell.parse(GroovyCodeSource) line: 706
      GroovyShell.parse(String, String) line: 742
      IDECompiler.compileScript(String, String) line: 28
      MainCompiler.compileScript(String, MetaDataSelector, String, String, List<Parameter>) line: 53
      SimpleDemo.main(String[]) line: 51

      Attachments

        Activity

          People

            Unassigned Unassigned
            x_MM1229 XueJun
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: