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

Casting fails after instanceof succeeds

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.0, 1.1-beta-2
    • 1.1-rc-3
    • None
    • None
    • Windows XP, Java 1.5

    Description

      The following code fails with the subsequent exception

      private boolean match(Service service)
      {
      // Once we've found our controller, don't try any more
      if (proofer == null && service instanceof Proofer)
      {
      if (service.getName().equalsIgnoreCase(prooferName))
      {
      LOG.info("here")
      proofer = (Proofer) Service
      LOG.info("there")
      controller = proofer.getConroller()
      if (controller.getName().equalsIgnoreCase(controllerName))

      { proofer.addConnectionListener(this) if (proofer.isReady()) connectionReady() return true }

      else

      { proofer == null controller == null }

      }
      }
      return false
      }

      ______________________
      INFO 2007.07.09 19:55:42,048 Z [Thread-25 Startup] ProoferViewerLauncher - here
      Exception in thread "Thread-25 Startup" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'class com.creo.proofer.service.Service' with class 'java.lang.Class' to class 'com.creo.proofer.service.Proofer'
      at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:331)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:623)
      at com.kodak.proofer.groovy.tools.ProoferViewerLauncher.match(ProoferViewerLauncher.groovy:61)
      at com.kodak.proofer.groovy.tools.ProoferViewerLauncher.this$2$match(ProoferViewerLauncher.groovy)
      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.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:52)
      at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:714)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:583)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:476)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:548)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurrentN(ScriptBytecodeAdapter.java:66)
      at com.kodak.proofer.groovy.tools.ProoferViewerLauncher$_initialize_closure1.doCall(ProoferViewerLauncher.groovy:117)
      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.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:52)
      at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:714)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:583)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:476)
      at groovy.lang.Closure.call(Closure.java:174)
      at groovy.lang.Closure.call(Closure.java:187)
      at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:848)
      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.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:52)
      at org.codehaus.groovy.runtime.NewInstanceMetaMethod.invoke(NewInstanceMetaMethod.java:90)
      at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:714)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:583)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:476)
      at org.codehaus.groovy.runtime.Invoker.invokePojoMethod(Invoker.java:104)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:77)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:85)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:158)
      at com.kodak.proofer.groovy.tools.ProoferViewerLauncher.initialize(ProoferViewerLauncher.groovy:115)
      at com.creo.proofer.service.ServiceRepository.addListener(ServiceRepository.java:101)
      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.groovy.runtime.metaclass.ReflectionMetaMethod.invoke(ReflectionMetaMethod.java:52)
      at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassHelper.java:714)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:583)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:476)
      at org.codehaus.groovy.runtime.Invoker.invokePojoMethod(Invoker.java:104)
      at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:77)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:85)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:158)
      at com.kodak.proofer.groovy.tools.ProoferViewerLauncher.<init>(ProoferViewerLauncher.groovy:50)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      at org.codehaus.groovy.runtime.MetaClassHelper.doConstructorInvoke(MetaClassHelper.java:563)
      at groovy.lang.MetaClassImpl.doConstructorInvoke(MetaClassImpl.java:1864)
      at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:804)
      at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:734)
      at org.codehaus.groovy.runtime.Invoker.invokeConstructorOf(Invoker.java:143)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:114)
      at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeNewN(ScriptBytecodeAdapter.java:214)
      at Startup.run(Startup.groovy:48)
      at java.lang.Thread.run(Thread.java:619)

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            kolotyluk Eric Kolotyluk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: