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

Parsing problem of number literal 0x8000000000000000L

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1, 2.1.0-beta-1
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      All

      Description

      I have the following small part of a java class:

          public class GBitMaskTest {
          
              @Test
              public void checkFirstBitTest() {
                  BitMask bm = new BitMask(0x8000000000000000L);
                  assertEquals(true, bm.isBitSet(63));
              }
          
          ...
          }
      

      which should be compilable in Groovy as well cause it's valid Java code. But i get the following:

          Groovy Bug --- exception in phase 'conversion' in source unit '/home/g-ut-example/src/test/groovy/com/soebes/training/maven/simple/GBitMaskTest.groovy' For input string: "8000000000000000"
          BUG! exception in phase 'conversion' in source unit '/home/g-ut-example/src/test/groovy/com/soebes/training/maven/simple/GBitMaskTest.groovy' For input string: "8000000000000000"
      

      This has happened with Groovy 2.0 in relationship with Maven. It's this example https://github.com/khmarbaise/maui/tree/master/src/main/resources/g-ut-example which produces this problem. I'm compiling with the following part:

            <build>
              <plugins>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <configuration>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                    <compilerArgument>nowarn</compilerArgument>
                    <verbose>true</verbose>
                  </configuration>
                  <dependencies>
                    <dependency>
                      <groupId>org.codehaus.groovy</groupId>
                      <artifactId>groovy-eclipse-compiler</artifactId>
                      <version>2.7.0-01</version>
                    </dependency>
                    <dependency>
                      <groupId>org.codehaus.groovy</groupId>
                      <artifactId>groovy-eclipse-batch</artifactId>
                      <version>2.0.0-01</version>
                    </dependency>
                  </dependencies>
                </plugin>
              </plugins>
            </build>
      

      The rest of the error message (EXception):

          GBitMaskTest.groovy' For input string: "8000000000000000"
          	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:1001)
          	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:624)
          	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:600)
          	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:577)
          	at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:171)
          	at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyParser.dietParse(GroovyParser.java:455)
          	at org.codehaus.jdt.groovy.integration.internal.MultiplexingParser.dietParse(MultiplexingParser.java:44)
          	at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:775)
          	at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:395)
          	at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:485)
          	at org.eclipse.jdt.internal.compiler.batch.Main.performCompilation(Main.java:3829)
          	at org.eclipse.jdt.internal.compiler.batch.Main.compile(Main.java:1682)
          	at org.codehaus.groovy.eclipse.compiler.GroovyEclipseCompiler.compile(GroovyEclipseCompiler.java:243)
          	at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:678)
          	at org.apache.maven.plugin.TestCompilerMojo.execute(TestCompilerMojo.java:161)
          	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
          	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
          	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
          	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
          	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
          	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
          	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
          	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
          	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
          	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
          	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
          	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
          	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          	at java.lang.reflect.Method.invoke(Method.java:597)
          	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
          	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
          	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
          	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
          Caused by: java.lang.NumberFormatException: For input string: "8000000000000000"
          	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
          	at java.lang.Long.parseLong(Long.java:422)
          	at org.codehaus.groovy.syntax.Numbers.parseInteger(Numbers.java:215)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.integerExpression(AntlrParserPlugin.java:3184)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expressionSwitch(AntlrParserPlugin.java:2153)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expression(AntlrParserPlugin.java:2018)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expression(AntlrParserPlugin.java:2008)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expressionSwitch(AntlrParserPlugin.java:2046)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expression(AntlrParserPlugin.java:2018)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expression(AntlrParserPlugin.java:2008)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.addArgumentExpression(AntlrParserPlugin.java:3071)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.arguments(AntlrParserPlugin.java:2994)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.constructorCallExpression(AntlrParserPlugin.java:2932)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expressionSwitch(AntlrParserPlugin.java:2069)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expression(AntlrParserPlugin.java:2018)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.expression(AntlrParserPlugin.java:2008)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.declarationExpression(AntlrParserPlugin.java:1776)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.variableDef(AntlrParserPlugin.java:1792)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.statement(AntlrParserPlugin.java:1513)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.statementListNoChild(AntlrParserPlugin.java:1599)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.statementList(AntlrParserPlugin.java:1574)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.methodDef(AntlrParserPlugin.java:1045)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.objectBlock(AntlrParserPlugin.java:800)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.innerClassDef(AntlrParserPlugin.java:783)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.classDef(AntlrParserPlugin.java:677)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.convertGroovy(AntlrParserPlugin.java:361)
          	at org.codehaus.groovy.antlr.AntlrParserPlugin.buildAST(AntlrParserPlugin.java:269)
          	at org.codehaus.groovy.control.SourceUnit.convert(SourceUnit.java:302)
          	at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:706)
          	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:992)
          	... 35 more
      

        Attachments

          Activity

            People

            • Assignee:
              Guillaume Guillaume Delcroix
              Reporter:
              khmarbaise Karl Heinz Marbaise
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: