Error Instantiating the class

30 views
Skip to first unread message

Teja

unread,
Apr 25, 2011, 10:03:28 AM4/25/11
to gosu-lang
I am trying to create a very basic class and instantiate it to test. I
am getting a strange error with no clue. Any help??

Poll.gs
-----------

package com;

class Poll {

}


Test.gsp
---------------
uses com.Poll;

var v = new Poll()


Running the Test.gsp is throwing this error,

gw.lang.parser.exceptions.ParseResultsException: Errors:

Constructor has internal access [line:3 col:18] in
line 2:
line 3: var v = new Poll()
Line Number: 3 Column: 18


at
gw.internal.gosu.parser.ParserBase.verifyParsedElement(ParserBase.java:
250)
at gw.internal.gosu.parser.GosuParser.parseProgram(GosuParser.java:
624)
at gw.internal.gosu.parser.GosuParser.parseProgram(GosuParser.java:
533)
at gw.lang.shell.Gosu.main(Gosu.java:100)


Thanks in advance,
Teja

Carson Gross

unread,
Apr 25, 2011, 11:10:57 AM4/25/11
to gosu...@googlegroups.com
Teja,

I think that the problem is that your program doesn't know where to find the Poll class.  How do you have your project laid out?

A "standard" pattern is to have something like this:

  /src
      /com/Poll.gs
  /bin
      /Test.gsp

and then have the following classpath entry at the start of your Test.gsp:

  classpath "../src"

Programs don't have a notion of "where" they are relative to other gosu resources.  You have to explicitly tell the program where to find other stuff using the classpath statement (which must be the first thing in the program.)  I'd like to think this is an improvement over java (where you usually have to create a separate script to launch things) or ruby (where things usually end up being global) but it does require a bit of work.

Hope that helps.

Cheers,
Carson


--
You received this message because you are subscribed to the Google Groups "gosu-lang" group.
To post to this group, send email to gosu...@googlegroups.com.
To unsubscribe from this group, send email to gosu-lang+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gosu-lang?hl=en.


Teja Kantamneni

unread,
Apr 25, 2011, 4:07:29 PM4/25/11
to gosu...@googlegroups.com
Carson,

Thanks for the reply. But it didn't worked. FYI, I am using eclipse plugin and I attached the zip archive of my project to show the structure of the program.

Thanks,
Teja
test.zip

Carson Gross

unread,
Apr 25, 2011, 4:30:26 PM4/25/11
to gosu...@googlegroups.com
Teja,

Hmmm.  What I see when I unzip your project is this:

/src
    /com
           /Poll.class
/bin
   /com
         /Poll.gs
         /Test.gsp

That .class file makes me think that Poll started off life as a Java class, rather than a Gosu class, and that gosu is resolving *that* java-based file, rather than the gosu-based class in your bin directory.  That makes some sense, because in Java the source you gave for Poll.gs *would* actually be package-local (which is java's default.)

Here's what I'd recommend:

Delete /src/com/Poll.class
Move Poll.gs over to /src/com/Poll.gs
Move Test.gsp to /bin/Test.gsp

And set up the classpath the way I mentioned earlier.  At that point I *think* things should work.

Also, I should note that our IDE support is pretty old, and we expect to have updated versions out Real Soon Now(tm)

Cheers,
Carson
Reply all
Reply to author
Forward
0 new messages