Groovy Shell can't see imported classes without explicitly specifying entire package?

IntelliJIDEA 12.1.3 Community Edition
Groovy Version: 2.1.3 JVM: 1.7.0_21 Vendor: Oracle Corporation OS: Windows 7
Windows 7 64bit

I can do the following with a Groovy Shell started from the command line:

    groovy:000> import java.nio.ByteBuffer
    ===> [import java.nio.ByteBuffer]
    groovy:000> b = [0,1,2,3,4,5] as byte[]
    ===> [B@50c82a01
    groovy:000> bb = ByteBuffer.wrap(b)
    ===> java.nio.HeapByteBuffer[pos=0 lim=6 cap=6]
    groovy:000> bb.get(1)
    ===> 1
    groovy:000> bb.get(5)
    ===> 5
    groovy:000> bb
    ===> java.nio.HeapByteBuffer[pos=0 lim=6 cap=6]
    groovy:000> bb.get()
    ===> 0
    groovy:000> bb
    ===> java.nio.HeapByteBuffer[pos=1 lim=6 cap=6]

However, when I use Tools -> Groovy Shell from within IntelliJ, and try the same thing I get:

    > import java.nio.ByteBuffer
    > b = [0,1,2,3,4,5] as byte[]
    [0, 1, 2, 3, 4, 5]
    > b
    [0, 1, 2, 3, 4, 5]
    > bb = ByteBuffer.wrap(b)
    groovy.lang.MissingPropertyException: No such property: ByteBuffer for class: ideaGroovyConsole
            at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
            at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
            at ideaGroovyConsole.run(ideaGroovyConsole.groovy:1)
            at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:257)
            at groovy.lang.GroovyShell.run(GroovyShell.java:481)
            at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:601)
            at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:231)
            at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:64)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
            at console.run(console.txt:25)
            at groovy.ui.GroovyMain.processReader(GroovyMain.java:531)
            at groovy.ui.GroovyMain.processFiles(GroovyMain.java:441)
            at groovy.ui.GroovyMain.run(GroovyMain.java:341)
            at groovy.ui.GroovyMain.process(GroovyMain.java:329)
            at groovy.ui.GroovyMain.processArgs(GroovyMain.java:118)
            at groovy.ui.GroovyMain.main(GroovyMain.java:98)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:601)
            at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
            at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:601)
            at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:121)

I have to do the following to get this to work:

    > bb = java.nio.ByteBuffer.wrap(b)
    java.nio.HeapByteBuffer[pos=0 lim=6 cap=6]

Is this a bug?

Please sign in to leave a comment.