classes

162 views
Skip to first unread message

עדי סלומי

unread,
Apr 22, 2013, 5:14:54 AM4/22/13
to ceylon...@googlegroups.com
I wrote a class in the run file..is that wrong (I had an exception from java.lang.ClassNotFoundException)?
in what file should I declare the classes so it will not happen?
my code looks like that:
void run()
{
.
.
Writer writer=Writer(file)
.
}
class Writer(File fileout
{
.
.
.
.
)

Stephane Epardaud

unread,
Apr 22, 2013, 5:32:32 AM4/22/13
to ceylon...@googlegroups.com
Can you give us the full exception stack?


--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users...@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at http://groups.google.com/group/ceylon-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Stéphane Épardaud

עדי סלומי

unread,
Apr 22, 2013, 5:47:59 AM4/22/13
to ceylon...@googlegroups.com
the exception was written this way:
Exception in thread main java.lang.NoClassDefFoundError...........
Caused by: java.lang.ClassNotFoundException: step2.Writer
            at  java.net.URLClassLoader$1.run(Unknown source)
            at  java.net.URLClassLoader$1.run(Unknown source)
            at java.security.AccessController.doPrivilaged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown source)
            at java.net.URLClassLoader.loadClass(Unknown source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown source)
            ....3 more

Stephane Epardaud

unread,
Apr 22, 2013, 6:15:54 AM4/22/13
to ceylon...@googlegroups.com
And that happened how/when?

עדי סלומי

unread,
Apr 22, 2013, 6:33:51 AM4/22/13
to ceylon...@googlegroups.com
as you see in the first message I posted' I wrote a code in which the run function initialize an object typed Writer.
the debugger didnt make any error,but when I run the program there was displayed the Exception I wrote in my last post.
what is the problem?
thank you for your help!

Stephane Epardaud

unread,
Apr 22, 2013, 6:57:41 AM4/22/13
to ceylon...@googlegroups.com
I think what you call the debugger is called an IDE. Can you send us the whole project by zip please?

עדי סלומי

unread,
Apr 23, 2013, 4:50:17 AM4/23/13
to ceylon...@googlegroups.com
I geuss you're right..the project is added..
thanks!

בתאריך יום שני, 22 באפריל 2013 13:57:41 UTC+3, מאת Stéphane Épardaud:
ProjectSteps.zip

Jean-Charles Roger

unread,
Apr 23, 2013, 5:11:17 AM4/23/13
to ceylon...@googlegroups.com
Hi,

I've took a quick look to your project.

Here a set of problems I've seen:
- I removed all non UTF-8 characters in files.
- The ':=' assignment operator isn't valid, use '='.
- Use {String*} instead of String[],
- The module uses ceylon.file '0.4' which isn't 0.5 compatible. I had to change it to 0.5 and also re-export it (shared ceylon.file '0.5';).
- iterator isn't an attribute it's a function use 'iterator()', since functions can be assigned it can be confusing  :).
- When using string templates (````) the arguments must exist. You should checkit first. 


Hope it helps.

Jean-Charles.

Stephane Epardaud

unread,
Apr 23, 2013, 9:01:31 AM4/23/13
to ceylon...@googlegroups.com
Hey, thanks a lot Jean-Charles for your help ! :)

So it looks like you're using an older code base and we did change a lot of things in the syntax in 0.5, that seems to be the cause of your issues.


--
You received this message because you are subscribed to the Google Groups "ceylon-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-users...@googlegroups.com.
To post to this group, send email to ceylon...@googlegroups.com.
Visit this group at http://groups.google.com/group/ceylon-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Stéphane Épardaud

עדי סלומי

unread,
Apr 24, 2013, 2:24:29 AM4/24/13
to ceylon...@googlegroups.com
thank for you two..:)
my Ceylon version is 0.4 and not 0.5 as you realize..so variables have to be assigned by := operator, and I could'nt use iterator() instead of iterator-it made new  errors. and..there was not any use of String[]
Now,do you think you can help me in another way? I tried to change the code as Jean suggested,but then I had even more errors(syntax errors)
I would like you to look again at my code and tell me what the problem in 0.4 version..
Thanks!

בתאריך יום שלישי, 23 באפריל 2013 16:01:31 UTC+3, מאת Stéphane Épardaud:

Jean-Charles Roger

unread,
Apr 24, 2013, 2:28:34 AM4/24/13
to ceylon...@googlegroups.com
I understand why they were so many differences :).

Would you consider using Ceylon M5 ?
I use ceylon since M5, so I won't be able to help you much.

Jean-Charles.

עדי סלומי

unread,
Apr 24, 2013, 2:48:10 AM4/24/13
to ceylon...@googlegroups.com
Thank you anyway for wasting your own time to help me..
I hope someone else could help me with my version...

בתאריך יום רביעי, 24 באפריל 2013 09:28:34 UTC+3, מאת Jean-Charles:

Tako Schotanus

unread,
Apr 24, 2013, 3:29:31 AM4/24/13
to ceylon...@googlegroups.com
Hi,

you have to realize that all 0.x versions are pre-release versions that probably had some pretty big features missing as well as many known and unknown problems that we just can't spend any time on because we're trying to move forwards to a 1.0 release.

So I think it's in your best interest to switch to the 0.5 (and later to the upcoming 0.6) if you want any help with major problems you might be having. Version 0.4 is dead and buried. Some questions might be easy to respond to and we won't mind, but anything that would take more time realistically just isn't going to happen for a version that old.

We always help people out with the latest pre-release version (currently 0.5) but we also expect people to upgrade one when a new version arrives.

Cheers,
-Tako


-Tako

עדי סלומי

unread,
Apr 24, 2013, 3:57:41 AM4/24/13
to ceylon...@googlegroups.com, ta...@codejive.org
Ok..Can you tell me how to download the new version?

בתאריך יום רביעי, 24 באפריל 2013 10:29:31 UTC+3, מאת Tako Schotanus:

Stephane Epardaud

unread,
Apr 24, 2013, 4:03:30 AM4/24/13
to ceylon...@googlegroups.com
Same place you got the previous version? ;)

Tako Schotanus

unread,
Apr 24, 2013, 4:07:32 AM4/24/13
to ceylon...@googlegroups.com
BTW, make sure you have Java 7 installed!


-Tako

עדי סלומי

unread,
Apr 24, 2013, 9:45:38 AM4/24/13
to ceylon...@googlegroups.com, ta...@codejive.org
should I install Eclipse Indigo Sr2 Packages

בתאריך יום רביעי, 24 באפריל 2013 11:07:32 UTC+3, מאת Tako Schotanus:

Stephane Epardaud

unread,
Apr 24, 2013, 10:00:42 AM4/24/13
to ceylon...@googlegroups.com
You should try Juno instead and no need for Java EE if you don't do Java EE, the Java developper edition is enough.

עדי סלומי

unread,
Apr 24, 2013, 10:18:05 AM4/24/13
to ceylon...@googlegroups.com
sorry for disturbing you...could look at this sitehttp://eclipse.org/downloads/ and tell me what exactly should I download? thanks a lot!

בתאריך יום רביעי, 24 באפריל 2013 17:00:42 UTC+3, מאת Stéphane Épardaud:

Tako Schotanus

unread,
Apr 24, 2013, 10:26:26 AM4/24/13
to ceylon...@googlegroups.com

עדי סלומי

unread,
Apr 25, 2013, 4:11:09 AM4/25/13
to ceylon...@googlegroups.com, ta...@codejive.org

do I have to download Juno or Indigo would be fine?(my computer does'nt allow to download it)
בתאריך יום רביעי, 24 באפריל 2013 17:26:26 UTC+3, מאת Tako Schotanus:

Gavin King

unread,
Apr 25, 2013, 7:56:32 AM4/25/13
to ceylon...@googlegroups.com, ta...@codejive.org
I recommend Juno, because it can be a pain to convince Indigo to run on Java 7.
Gavin King
ga...@ceylon-lang.org
http://profiles.google.com/gavin.king
http://ceylon-lang.org
http://hibernate.org
http://seamframework.org

עדי סלומי

unread,
Apr 27, 2013, 3:24:05 PM4/27/13
to ceylon...@googlegroups.com, ta...@codejive.org
I downloaded the command line of ceylon 0.5. Now I have it as a directory contains different files..Now what should I do to install it?the directory contains the files:
bin,doc,lib,reopo,samples,templates,LISENCE-ASL,LICENSE-GPL,LICENSE-LGPL,NOTICE,README

בתאריך יום חמישי, 25 באפריל 2013 14:56:32 UTC+3, מאת Gavin King:

עדי סלומי

unread,
Apr 28, 2013, 11:16:32 AM4/28/13
to ceylon...@googlegroups.com, ta...@codejive.org
please, help me!! I have to know how to run the command line of Java! and what should I write in the module.ceylon and in run.ceylon files,so I could use file package?

בתאריך יום שבת, 27 באפריל 2013 22:24:05 UTC+3, מאת עדי סלומי:

עדי סלומי

unread,
Apr 28, 2013, 11:43:50 AM4/28/13
to ceylon...@googlegroups.com
Now I'm using Ceylon version 0.5..
I tried to check the condition if(exists currentfile) but the IDE writes :referenced value is non-constant(assign to a new local value to narrow file). I don't know how to fix this error..what do you think I should do? thanks!!

בתאריך יום שלישי, 23 באפריל 2013 12:11:17 UTC+3, מאת Jean-Charles:

Tom Bentley

unread,
Apr 28, 2013, 12:02:24 PM4/28/13
to ceylon...@googlegroups.com
The problem is that the `foo` in `if (exists foo)` is not a constant. So it could change from being non-null at the point the test is made to being null when the value is used in the block protected by the `if`, so the compile doesn't let you. You can use `if (exists bar=foo)`, so you have a constant value (bar) that you can use instead of foo inside the block.

Hope that helps,

Tom


עדי סלומי

unread,
Apr 28, 2013, 12:23:17 PM4/28/13
to ceylon...@googlegroups.com, tom.b...@cantab.net
thanks a lot! I have now anoter error...the compiler refers to some places in the program as errors and I don't understand whats the problem..
the compiler wrote this:
type occurs in a declaration that is visible outside this module, but comes from an imported module that is not re-exported: Parser
type occurs in a declaration that is visible outside this module, but comes from an imported module that is not re-exported: CodeWriter
type occurs in a declaration that is visible outside this module, but comes from an imported module that is not re-exported: fileInput
type occurs in a declaration that is visible outside this module, but comes from an imported module that is not re-exported: setFileInname

בתאריך יום ראשון, 28 באפריל 2013 19:02:24 UTC+3, מאת Tom Bentley:

Tom Bentley

unread,
Apr 28, 2013, 12:38:45 PM4/28/13
to ceylon...@googlegroups.com
Those declarations come from another module and are part of your module's public API, so you need to annotate the dependency (in the module.ceylon) with `shared`. This is mentioned in Stef's recent blog post
http://ceylon-lang.org/blog/2013/04/11/about-modules/#the_undeclared_implicit_dependency_problem (it's probably worth reading the whole blog post)

Tom

עדי סלומי

unread,
Apr 28, 2013, 2:30:02 PM4/28/13
to ceylon...@googlegroups.com, tom.b...@cantab.net
Ok..but I did'nt use some modules..I just created one ceylon module and in the file run.ceylon I declared all the classes(CodeWriter,Parser), and..they're annotated with shared. So what is the problem with it?(maybe I didn't understand you...:()

בתאריך יום ראשון, 28 באפריל 2013 19:38:45 UTC+3, מאת Tom Bentley:

Jean-Charles Roger

unread,
Apr 28, 2013, 2:46:12 PM4/28/13
to ceylon...@googlegroups.com
If recall, the module file (module.ceylon) contains: 
import ceylon.file '0.5';

Since your module presents the type File in shared methods the import should be shared as well:
shared import ceylon.file '0.5';

Jean-Charles.

עדי סלומי

unread,
Apr 28, 2013, 5:53:20 PM4/28/13
to ceylon...@googlegroups.com
thank you!! 
I run the program but I had this message:
Exception in thread "main" java.lang.RuntimeException: java.lang.NoClassDefFoundError: step2/CodeWriter
at com.redhat.ceylon.compiler.java.runtime.ide.Launcher.invokeMain(Launcher.java:86)
at com.redhat.ceylon.compiler.java.runtime.ide.Launcher.main(Launcher.java:53)
Caused by: java.lang.NoClassDefFoundError: step2/CodeWriter
at step2.readDirectory_.readDirectory(run.ceylon:19)
at step2.run_.run(run.ceylon:4)
at step2.run_.main(run.ceylon)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.redhat.ceylon.compiler.java.runtime.ide.Launcher.invokeMain(Launcher.java:73)
... 1 more
Caused by: java.lang.ClassNotFoundException: step2.CodeWriter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 9 more
what is it now?
I added the code so you could take a look..

בתאריך יום ראשון, 28 באפריל 2013 21:46:12 UTC+3, מאת Jean-Charles:
newProject.zip

עדי סלומי

unread,
Apr 29, 2013, 3:44:01 AM4/29/13
to ceylon...@googlegroups.com

please please please!! tell what is the problem with my project :)
בתאריך יום שני, 29 באפריל 2013 00:53:20 UTC+3, מאת עדי סלומי:

Jean-Charles Roger

unread,
Apr 29, 2013, 4:03:17 AM4/29/13
to ceylon...@googlegroups.com
When I compile your project using ceylon compile I get the error:

An exception has occurred in the compiler (ceylonc 0.5 (Nesa Pong)).
java.lang.NullPointerException
at com.sun.tools.javac.tree.TreeInfo.endPos(TreeInfo.java:251)
at com.sun.tools.javac.jvm.Gen.genTry(Gen.java:1369)
at com.sun.tools.javac.jvm.Gen.visitTry(Gen.java:1349)
at com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1046)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:684)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:719)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:705)
at com.sun.tools.javac.jvm.Gen.genStats(Gen.java:756)
at com.sun.tools.javac.jvm.Gen.visitBlock(Gen.java:1031)
at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:783)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:684)
at com.sun.tools.javac.jvm.Gen.genStat(Gen.java:719)
at com.sun.tools.javac.jvm.Gen.genMethod(Gen.java:912)
at com.sun.tools.javac.jvm.Gen.visitMethodDef(Gen.java:885)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:671)
at com.sun.tools.javac.jvm.Gen.genDef(Gen.java:684)
at com.sun.tools.javac.jvm.Gen.genClass(Gen.java:2233)
at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.genCodeUnlessError(LanguageCompiler.java:573)
at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.genCode(LanguageCompiler.java:551)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1449)
at com.redhat.ceylon.compiler.java.tools.LanguageCompiler.generate(LanguageCompiler.java:632)
at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1417)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:870)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:829)
at com.redhat.ceylon.compiler.java.launcher.Main.compile(Main.java:431)
at com.redhat.ceylon.compiler.java.launcher.Main.compile(Main.java:349)
at com.redhat.ceylon.compiler.java.launcher.Main.compile(Main.java:339)
at com.redhat.ceylon.compiler.CeylonCompileTool.run(CeylonCompileTool.java:256)
at com.redhat.ceylon.tools.CeylonTool.run(CeylonTool.java:236)
at com.redhat.ceylon.tools.CeylonTool.bootstrap(CeylonTool.java:205)
at com.redhat.ceylon.tools.CeylonTool.start(CeylonTool.java:178)
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.redhat.ceylon.launcher.Launcher.run(Launcher.java:68)
at com.redhat.ceylon.launcher.Launcher.main(Launcher.java:19)
Note: Created module step2/1.0.0
ceylon compile: There were 4 errors
[Finished in 10.7s with exit code 1]


It seems that you ran into a compiler problem. 
There is no code generated, that's why you can't run it.

Jean-Charles.


<newProject.zip>

Stephane Epardaud

unread,
Apr 29, 2013, 4:04:53 AM4/29/13
to ceylon...@googlegroups.com
OK let me look at that.
Stéphane Épardaud

Jean-Charles Roger

unread,
Apr 29, 2013, 4:05:46 AM4/29/13
to ceylon...@googlegroups.com
Thanks.

עדי סלומי

unread,
Apr 29, 2013, 4:06:57 AM4/29/13
to ceylon...@googlegroups.com

Ok..then what shold I do to fix it?
בתאריך יום שני, 29 באפריל 2013 11:03:17 UTC+3, מאת Jean-Charles:

Tako Schotanus

unread,
Apr 29, 2013, 4:11:50 AM4/29/13
to ceylon...@googlegroups.com
Just as a minor detail: could you tell us what character encoding your computer uses? It's obviously not ISO-8859-1 :)


-Tako

Jean-Charles Roger

unread,
Apr 29, 2013, 4:16:00 AM4/29/13
to ceylon...@googlegroups.com
I removed comments (using the regex "//[^"\n]+$") to avoid encoding problems.

Jean-Charles

Tako Schotanus

unread,
Apr 29, 2013, 4:15:53 AM4/29/13
to ceylon...@googlegroups.com
Ah found it ISO-8859-8 , for *other* people who want to compile without having to remove the non-UTF-8 chars you can add "--encoding iso-8859-8" to the command line. Or if you have the latest compiler from master you can add "encoding=iso-8859-8" to the "defaults" section of the projects .ceylon/config file.


-Tako

Stephane Epardaud

unread,
Apr 29, 2013, 4:18:24 AM4/29/13
to ceylon...@googlegroups.com
Encoding is not the problem. The problem is at line 252 there's a "try" with no catch or finally. Fix this and it compiles. I'll file a bug for that.
Stéphane Épardaud

עדי סלומי

unread,
Apr 29, 2013, 4:18:43 AM4/29/13
to ceylon...@googlegroups.com, ta...@codejive.org

don't laugh.., but I dont know..how can I know that?tell me and  I will check..
בתאריך יום שני, 29 באפריל 2013 11:11:50 UTC+3, מאת Tako Schotanus:

עדי סלומי

unread,
Apr 29, 2013, 4:24:14 AM4/29/13
to ceylon...@googlegroups.com
thanks!!!!
one more question..:(
when I read/write to file I have to block it with try-catch?
בתאריך יום שני, 29 באפריל 2013 11:18:24 UTC+3, מאת Stéphane Épardaud:

Stephane Epardaud

unread,
Apr 29, 2013, 4:25:34 AM4/29/13
to ceylon...@googlegroups.com
You don't have to use try/catch if you don't intend to catch exceptions or do anything in the finally ;)

עדי סלומי

unread,
Apr 29, 2013, 4:34:09 AM4/29/13
to ceylon...@googlegroups.com

thanks all of you!!!!
בתאריך יום שני, 29 באפריל 2013 11:25:34 UTC+3, מאת Stéphane Épardaud:

Tako Schotanus

unread,
Apr 29, 2013, 7:00:56 AM4/29/13
to ceylon...@googlegroups.com
You're welcome.

Btw, these lines:

value filePath = parsePath(dir.string).childPath("HackCode"+i.string+".asm");
if (is Nil loc = filePath.resource)//if HackCodei.asm does not exist

can probably be easier written like this:

if (is Nil loc = dir.childResource("HackCode"+i.string+".asm"))//if HackCodei.asm does not exist

it's a little less going back and forth between strings and paths.

Good luck!

-Tako



-Tako

עדי סלומי

unread,
May 16, 2013, 6:05:19 AM5/16/13
to ceylon...@googlegroups.com, ta...@codejive.org
hi!
is there a method that replaces some string to another one? I mean, if I have two strings f and s and i want to operate f=s..how can I do that? thanks!

בתאריך יום שני, 29 באפריל 2013 14:00:56 UTC+3, מאת Tako Schotanus:

Tako Schotanus

unread,
May 16, 2013, 6:57:22 AM5/16/13
to ceylon...@googlegroups.com
If what you're looking for is a variable, something that you can change the value of, you can annotate it "variable", like this:

    variable String changingValue = "first string";
    changingValue = "second string";
    String third = "third string";
    changingValue = third;

Hope this answers your question!

-Tako



-Tako

עדי סלומי

unread,
May 16, 2013, 9:04:00 AM5/16/13
to ceylon...@googlegroups.com, ta...@codejive.org
thank you for trying to help..
 I have an attribute line defined String? line;. I had to write the condition if(exists line) so I could use it as a String.
Then I tried to do that: line.replace(line,line.span(i,line.size));
but replace is not the right method to do what I want..do you know another way to assign line.span(i,line.size) in line?
thanks :)

בתאריך יום חמישי, 16 במאי 2013 13:57:22 UTC+3, מאת Tako Schotanus:

Stephane Epardaud

unread,
May 16, 2013, 9:47:15 AM5/16/13
to ceylon...@googlegroups.com
line = line.span(i, line.size);

Or even line = line[i...];

עדי סלומי

unread,
May 16, 2013, 10:15:12 AM5/16/13
to ceylon...@googlegroups.com
thank you!
do you know if there's a method that casts from String to Integer?

בתאריך יום חמישי, 16 במאי 2013 16:47:15 UTC+3, מאת Stéphane Épardaud:

Roland Tepp

unread,
May 16, 2013, 10:20:13 AM5/16/13
to ceylon...@googlegroups.com
Integer intValueOfLine = parseInteger(line).

Also, feel free to consult language module API documentation:
http://modules.ceylon-lang.org/test/ceylon/language/0.5/module-doc/index.html

Tako Schotanus

unread,
May 16, 2013, 10:38:52 AM5/16/13
to ceylon...@googlegroups.com
parseInteger("42")


-Tako
Reply all
Reply to author
Forward
0 new messages