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

Project compilation fails when I put an enum in my project

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.1.3, 2.2.0-beta-1
    • Component/s: Compiler
    • Labels:
      None

      Description

      If I put the following enum class in my project source code, compilation fails for the project and a red mark is put on "line 0" of this enum class and on another class:

      General error during class generation: Index: 0, Size: 0 java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at 
       java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at 
       org.codehaus.groovy.classgen.asm.InvocationWriter.writeAICCall(InvocationWriter.java:459) at 
       org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeConstructor(InvocationWriter.java:430) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorCallExpression(AsmClassGenerator.java:908) at 
       org.codehaus.groovy.ast.expr.ConstructorCallExpression.visit(ConstructorCallExpression.java:43) at 
       org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:301) at 
       org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:231) at 
       org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:76) at 
       org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:60) at 
       org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:336) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:647) at 
       org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:67) at 
       org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:584) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:504) at 
       org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47) at 
       org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:81) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:454) at 
       org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at 
       org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:102) at 
       org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:113) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:318) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:275) at 
       org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:124) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:395) at 
       org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1174) at 
       org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:51) at 
       org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:179) at 
       org.codehaus.groovy.control.CompilationUnit$6.call(CompilationUnit.java:857) at 
       org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1191) at 
       org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:623) at 
       org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:601) at 
       org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:578) at 
       org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilati
       onUnitDeclaration.java:171) at 
       org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.generateCode(GroovyCompilatio
       nUnitDeclaration.java:1534) at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:986) at 
       org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:1025) at 
       org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:209) at 
       org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:275) at 
       org.codehaus.jdt.groovy.model.GroovyReconcileWorkingCopyOperation.makeConsistent(GroovyReconcileWorking
       CopyOperation.java:80) at 
       org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.ja
       va:89) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at 
       org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788) at 
       org.codehaus.jdt.groovy.model.GroovyCompilationUnit.reconcile(GroovyCompilationUnit.java:429) at 
       org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126) at 
       org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108) at 
       org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89) at 
       org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at 
       org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87) at 
       org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151) at 
       org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86) at 
       org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:
       104) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77) at 
       org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
      

      The enum class that is giving problem is the following:

      package com.utopicmusic.app.web.seo
      
      import java.sql.SQLException
      
      import org.hibernate.HibernateException
      import org.hibernate.Session
      import org.springframework.orm.hibernate3.HibernateCallback
      import org.springframework.orm.hibernate3.HibernateTemplate
      
      
      
      /**
       * Type of sitemap that can be generated.
       * 
       * @author Mauro Molinari
       */
      enum SitemapType {
      
      	/** Sitemap index. */
      	INDEX {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate) {
      			final def result = [:]
      			// index for artists
      			// count
      			//int c = ARTISTS.countEntries(hibernateTemplate)
      
      			return result
      		}
      
      		@Override
      		String getTemplatePath() {
      			getClass().package.name.replace('.', '/') + '/sitemap-index.ftl'
      		}
      	},
      
      	/** Sitemap for artist public pages. */
      	ARTISTS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      
      		@Override
      		int countEntries(final HibernateTemplate hibernateTemplate) {
      			hibernateTemplate.execute(new HibernateCallback<Integer>() {
      						@Override
      						public Integer doInHibernate(Session session) throws HibernateException, SQLException {
      							return session.createQuery("select count(artist) from Artist as artist join artist.owner as user where user.active and artist.active").uniqueResult()
      						}
      					})
      		}
      	},
      
      	/** Sitemap for club public pages. */
      	CLUBS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      	},
      
      	/** Sitemap for listener public pages. */
      	LISTENERS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      	},
      
      	/** Sitemap for post pages. */
      	POSTS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      	},
      
      	/** Sitemap for song pages. */
      	SONGS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      	},
      
      	/** Sitemap for album pages. */
      	ALBUMS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      	},
      
      	/** Sitemap for playlist pages. */
      	PLAYLISTS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      	},
      
      	/** Sitemap for geographic pages. */
      	LOCATIONS {
      		@Override
      		Map buildModel(final int offset, final HibernateTemplate hibernateTemplate){
      		}
      	}
      
      	/**
      	 * Returns the path within the classpath of the template that can be used to
      	 * generate a sitemap of this type.
      	 *
      	 * @return the full path within the classpath to retrieve the template
      	 */
      	String getTemplatePath() {
      		getClass().package.name.replace('.', '/') + '/sitemap.ftl'
      	}
      
      	/**
      	 * Builds the model and view for a sitemap of this type.
      	 * <p>
      	 * Actually, only a part of sitemap is built, containing up to 30,000 links at most.
      	 *
      	 * @param offset the offset for the contents to include in the requested sitemap
      	 * @return the model and reference to the view name needed to generate this type of sitemap
      	 */
      	Map buildModel(final int offset, final HibernateTemplate hibernateTemplate) {
      		throw new UnsupportedOperationException('requested sitemap unavailable')
      	}
      
      	int countEntries(final HibernateTemplate hibernateTemplate) {
      		throw new UnsupportedOperationException('count not implemented for this sitemap type')
      	}
      }
      

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              mauromol Mauro Molinari
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: