Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #22563 > unrolled thread

Enum in Eclipse Scrapbook

Started byRobert Mark Bram <robertmarkbram@gmail.com>
First post2013-02-26 21:52 -0800
Last post2013-02-28 16:57 -0500
Articles 20 on this page of 24 — 7 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Enum in Eclipse Scrapbook Robert Mark Bram <robertmarkbram@gmail.com> - 2013-02-26 21:52 -0800
    Re: Enum in Eclipse Scrapbook markspace <markspace@nospam.nospam> - 2013-02-26 22:25 -0800
      Re: Enum in Eclipse Scrapbook Robert Mark Bram <robertmarkbram@gmail.com> - 2013-02-26 23:04 -0800
        Re: Enum in Eclipse Scrapbook Robert Mark Bram <robertmarkbram@gmail.com> - 2013-02-26 23:17 -0800
          Re: Enum in Eclipse Scrapbook markspace <markspace@nospam.nospam> - 2013-02-27 07:41 -0800
            Re: Enum in Eclipse Scrapbook Jim Janney <jjanney@shell.xmission.com> - 2013-02-27 09:53 -0700
            Re: Enum in Eclipse Scrapbook Robert Mark Bram <robertmarkbram@gmail.com> - 2013-02-27 12:12 -0800
              Re: Enum in Eclipse Scrapbook Lew <lewbloch@gmail.com> - 2013-02-27 12:25 -0800
                Re: Enum in Eclipse Scrapbook lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-28 09:02 +0000
                  Re: Enum in Eclipse Scrapbook Arne Vajhøj <arne@vajhoej.dk> - 2013-02-28 08:28 -0500
                    Re: Enum in Eclipse Scrapbook lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-28 15:24 +0000
                      Re: Enum in Eclipse Scrapbook Arne Vajhøj <arne@vajhoej.dk> - 2013-02-28 16:48 -0500
                    Re: Enum in Eclipse Scrapbook Lew <lewbloch@gmail.com> - 2013-02-28 14:09 -0800
                      Re: Enum in Eclipse Scrapbook Arne Vajhøj <arne@vajhoej.dk> - 2013-03-03 21:24 -0500
                        Re: Enum in Eclipse Scrapbook Lew <lewbloch@gmail.com> - 2013-03-04 11:36 -0800
                          Re: Enum in Eclipse Scrapbook Arne Vajhøj <arne@vajhoej.dk> - 2013-03-07 14:19 -0500
                            Re: Enum in Eclipse Scrapbook Lew <lewbloch@gmail.com> - 2013-03-07 13:34 -0800
      Re: Enum in Eclipse Scrapbook Lew <lewbloch@gmail.com> - 2013-02-27 12:24 -0800
    Re: Enum in Eclipse Scrapbook Robert Mark Bram <robertmarkbram@gmail.com> - 2013-02-26 23:28 -0800
    Re: Enum in Eclipse Scrapbook lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-27 09:50 +0000
      Re: Enum in Eclipse Scrapbook Robert Mark Bram <robertmarkbram@gmail.com> - 2013-02-27 03:43 -0800
        Re: Enum in Eclipse Scrapbook lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-27 12:02 +0000
    Re: Enum in Eclipse Scrapbook Roedy Green <see_website@mindprod.com.invalid> - 2013-02-28 07:43 -0800
      Re: Enum in Eclipse Scrapbook Arne Vajhøj <arne@vajhoej.dk> - 2013-02-28 16:57 -0500

Page 1 of 2  [1] 2  Next page →


#22563 — Enum in Eclipse Scrapbook

FromRobert Mark Bram <robertmarkbram@gmail.com>
Date2013-02-26 21:52 -0800
SubjectEnum in Eclipse Scrapbook
Message-ID<515de149-3ee1-482d-a090-82ce264ed142@googlegroups.com>
Hi All,

Not sure if this is a bug or if I am going a bit crazy.. Am trying to do some quick testing of enums in an Eclipse jpage Scrapbook (using JDK 1.7.0_02, Win XP 64-bit, Eclipse Juno)

class A {
    enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
}
A a = new A();

When I try to execute this I get:

The member enum Month can only be defined inside a top-level class or interface

Alternatively, I try moving the enum out of the class definition as below:

enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
Month.valueOf("JAN");

These are the errors I got for the above:

The member enum Month can only be defined inside a top-level class or interface
Month cannot be resolved

Any advice would be appreciated!

Rob
:)

[toc] | [next] | [standalone]


#22564

Frommarkspace <markspace@nospam.nospam>
Date2013-02-26 22:25 -0800
Message-ID<kgk8pt$ih$1@dont-email.me>
In reply to#22563
On 2/26/2013 9:52 PM, Robert Mark Bram wrote:
> class A {
>      enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
> }
> A a = new A();
>
> When I try to execute this I get:
>
> The member enum Month can only be defined inside a top-level class or interface

What's the name of the file this is defined in?  Is it A.java?  What 
package is this defined in?

Ditto for the other file you tried.


[toc] | [prev] | [next] | [standalone]


#22565

FromRobert Mark Bram <robertmarkbram@gmail.com>
Date2013-02-26 23:04 -0800
Message-ID<4e2d049c-9a8b-420c-8dfd-293402e7bf95@googlegroups.com>
In reply to#22564
On Wednesday, 27 February 2013 17:25:07 UTC+11, markspace  wrote:
> On 2/26/2013 9:52 PM, Robert Mark Bram wrote:
> 
> > class A {
> 
> >      enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
> 
> > }
> 
> > A a = new A();
> 
> >
> 
> > When I try to execute this I get:
> 
> >
> 
> > The member enum Month can only be defined inside a top-level class or interface
> 
> 
> 
> What's the name of the file this is defined in?  Is it A.java?  What 
> 
> package is this defined in?
> 
> 
> 
> Ditto for the other file you tried.

It is an Eclipse Scrapbook page - a jpage file. There is no class as such.

Rob
:)

[toc] | [prev] | [next] | [standalone]


#22566

FromRobert Mark Bram <robertmarkbram@gmail.com>
Date2013-02-26 23:17 -0800
Message-ID<47939433-d698-4df5-8789-09c4d841fa88@googlegroups.com>
In reply to#22565
On Wednesday, 27 February 2013 18:04:20 UTC+11, Robert Mark Bram  wrote:
> It is an Eclipse Scrapbook page - a jpage file. There is no class as such.

Which most likely means that Eclipse shoves the code into a main method I guess.. which may simply mean I cannot declare an enum in a Scrapbook.

[toc] | [prev] | [next] | [standalone]


#22575

Frommarkspace <markspace@nospam.nospam>
Date2013-02-27 07:41 -0800
Message-ID<kgl9da$1tt$1@dont-email.me>
In reply to#22566
On 2/26/2013 11:17 PM, Robert Mark Bram wrote:
> On Wednesday, 27 February 2013 18:04:20 UTC+11, Robert Mark Bram
> wrote:
>> It is an Eclipse Scrapbook page - a jpage file. There is no class
>> as such.
>
> Which most likely means that Eclipse shoves the code into a main
> method I guess.. which may simply mean I cannot declare an enum in a
> Scrapbook.
>

No se hablo Eclipse Scapbook -- is that a plugin?  Like some sort of 
bean shell or copy-paste tool?

I'm used to class names matching file names;  when they don't you get 
errors like missing top-level classes and whatnot.  That's why I focused 
in on the file name.  I assumed you might have copied the code to a new 
file but forgotten to change the file name.

It does sound like a bug in whatever is doing the parsing here, or at 
least a missing feature.

[toc] | [prev] | [next] | [standalone]


#22577

FromJim Janney <jjanney@shell.xmission.com>
Date2013-02-27 09:53 -0700
Message-ID<ydn38whzoj4.fsf@shell.xmission.com>
In reply to#22575
markspace <markspace@nospam.nospam> writes:

> On 2/26/2013 11:17 PM, Robert Mark Bram wrote:
>> On Wednesday, 27 February 2013 18:04:20 UTC+11, Robert Mark Bram
>> wrote:
>>> It is an Eclipse Scrapbook page - a jpage file. There is no class
>>> as such.
>>
>> Which most likely means that Eclipse shoves the code into a main
>> method I guess.. which may simply mean I cannot declare an enum in a
>> Scrapbook.
>>
>
> No se hablo Eclipse Scapbook -- is that a plugin?  Like some sort of
> bean shell or copy-paste tool?
>
> I'm used to class names matching file names;  when they don't you get
> errors like missing top-level classes and whatnot.  That's why I
> focused in on the file name.  I assumed you might have copied the code
> to a new file but forgotten to change the file name.
>
> It does sound like a bug in whatever is doing the parsing here, or at
> least a missing feature.

The scrapbook is a special Eclipse buffer that lets you enter little
code snippets and evaluate them.  Since Java is not by nature a dynamic
language, it's not surprising that this doesn't always work perfectly.

-- 
Jim Janney

[toc] | [prev] | [next] | [standalone]


#22589

FromRobert Mark Bram <robertmarkbram@gmail.com>
Date2013-02-27 12:12 -0800
Message-ID<ac0f3558-fb23-4ca1-842f-9ab2a23e81d5@googlegroups.com>
In reply to#22575
On Thursday, 28 February 2013 02:41:36 UTC+11, markspace  wrote:
> No se hablo Eclipse Scapbook -- is that a plugin?  Like some sort of 
> bean shell or copy-paste tool?

No - it's in vanilla Eclipse, and it's pretty cool. 

This page gives some beginner's info on it: http://www.eclipsezone.com/eclipse/forums/t61137.html

Rob
:)

[toc] | [prev] | [next] | [standalone]


#22591

FromLew <lewbloch@gmail.com>
Date2013-02-27 12:25 -0800
Message-ID<500f1031-2d35-4bb4-a934-b0b96d8070ba@googlegroups.com>
In reply to#22589
Robert Mark Bram wrote:
> markspace  wrote:
>> No se hablo Eclipse Scapbook -- is that a plugin?  Like some sort of 
>> bean shell or copy-paste tool?
> 
> No - it's in vanilla Eclipse, and it's pretty cool. 
> 
> This page gives some beginner's info on it: http://www.eclipsezone.com/eclipse/forums/t61137.html

Nowhere does it state that its purpose is to define complex classes. Its purpose is to execute expressions.

So define your classes where you're supposed to, in their own source files.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22611

Fromlipska the kat <"nospam at neversurrender dot co dot uk">
Date2013-02-28 09:02 +0000
Message-ID<EeidnUocz5WggLLMnZ2dnUVZ7rSdnZ2d@bt.com>
In reply to#22591
On 27/02/13 20:25, Lew wrote:
> Robert Mark Bram wrote:
>> markspace  wrote:
>>> No se hablo Eclipse Scapbook -- is that a plugin?  Like some sort of
>>> bean shell or copy-paste tool?
>>
>> No - it's in vanilla Eclipse, and it's pretty cool.
>>
>> This page gives some beginner's info on it: http://www.eclipsezone.com/eclipse/forums/t61137.html
>
> Nowhere does it state that its purpose is to define complex classes. Its purpose is to execute expressions.
>
> So define your classes where you're supposed to, in their own source files.

Have you even tried this ?

the scrap

//
enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};

Month m = Month.JAN;
//

is not a 'complex class'

Month m = Month.JAN;

is an expression, yet it still fails.

Why don't you try it for yourself and report back ... or is that a bit 
too much like 'social interaction' to be comfortable for you.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#22616

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-02-28 08:28 -0500
Message-ID<512f5b83$0$283$14726298@news.sunsite.dk>
In reply to#22611
On 2/28/2013 4:02 AM, lipska the kat wrote:
> On 27/02/13 20:25, Lew wrote:
>> Robert Mark Bram wrote:
>>> markspace  wrote:
>>>> No se hablo Eclipse Scapbook -- is that a plugin?  Like some sort of
>>>> bean shell or copy-paste tool?
>>>
>>> No - it's in vanilla Eclipse, and it's pretty cool.
>>>
>>> This page gives some beginner's info on it:
>>> http://www.eclipsezone.com/eclipse/forums/t61137.html
>>
>> Nowhere does it state that its purpose is to define complex classes.
>> Its purpose is to execute expressions.
>>
>> So define your classes where you're supposed to, in their own source
>> files.
>
> Have you even tried this ?
>
> the scrap
>
> //
> enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};
>
> Month m = Month.JAN;
> //
>
> is not a 'complex class'
>
> Month m = Month.JAN;
>
> is an expression, yet it still fails.

The original example was also an expression.

But both the original example and your example
contains a nested type.

And apparently scrapbook does not support nested types.

So the solution is to move the nested types out as top
level types.

As Lew said. Assuming that we consider enum a class.

Arne

[toc] | [prev] | [next] | [standalone]


#22620

Fromlipska the kat <"nospam at neversurrender dot co dot uk">
Date2013-02-28 15:24 +0000
Message-ID<h4idnZpxhfpZ67LMnZ2dnUVZ8vSdnZ2d@bt.com>
In reply to#22616
On 28/02/13 13:28, Arne Vajhøj wrote:
> On 2/28/2013 4:02 AM, lipska the kat wrote:
>> On 27/02/13 20:25, Lew wrote:
>>> Robert Mark Bram wrote:

[snip]

> The original example was also an expression.
>
> But both the original example and your example
> contains a nested type.

It's not my example you buffoon, it's the OPs

It really is amazing how many times a problem is posed and a solution 
suggested or achieved only for you to pop up well after the fact, making 
like you knew the answer all along.

Do you ever tire of talking bollocks.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#22633

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-02-28 16:48 -0500
Message-ID<512fd0b4$0$289$14726298@news.sunsite.dk>
In reply to#22620
On 2/28/2013 10:24 AM, lipska the kat wrote:
> On 28/02/13 13:28, Arne Vajhøj wrote:
>> On 2/28/2013 4:02 AM, lipska the kat wrote:
 >>>On 27/02/13 20:25, Lew wrote:
 >>>>Nowhere does it state that its purpose is to define complex 
classes. Its purpose is to execute expressions.
 >>>>
 >>>>So define your classes where you're supposed to, in their own 
source files.
 >>>>
>>>
>>>enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};
>>>
>>>Month m = Month.JAN;
>>>
 >>>is not a 'complex class'
 >>>
 >>>Month m = Month.JAN;
 >>>
 >>>is an expression, yet it still fails.
 >>
>> The original example was also an expression.
>>
>> But both the original example and your example
>> contains a nested type.
 >>
 >>And apparently scrapbook does not support nested types.
 >>
 >>So the solution is to move the nested types out as top
level types.
 >>
 >>As Lew said. Assuming that we consider enum a class.
>
> It's not my example you buffoon, it's the OPs

No.

OP's example was:

class A {
     enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
}
A a = new A();

So it is:

implicit class - nested enum

and:

implicit class - nested class - nested enum

OP's example gives 1 error.

Your example give 3 errors (where the first is the
one in OP's example).

So Lew's comment is absolutely correct - moving class A out
as a top level class in its own file will solve the problem.

For reasons unknown to me you posted a similar but not identical
example.

Lew's solution still applies though - just by moving the enum
Month out as top level.

So stop whining and express your admiration that Lew analyzed
the problem correctly.

Arne

[toc] | [prev] | [next] | [standalone]


#22638

FromLew <lewbloch@gmail.com>
Date2013-02-28 14:09 -0800
Message-ID<3cd361c6-6a12-466c-aafd-4da7cbb1d49e@googlegroups.com>
In reply to#22616
Arne Vajhøj wrote:
> ... Assuming that we consider enum a class.

It doesn't matter what you assume or consider, an enum is a class.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22699

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-03-03 21:24 -0500
Message-ID<513405f1$0$32110$14726298@news.sunsite.dk>
In reply to#22638
On 2/28/2013 5:09 PM, Lew wrote:
> Arne Vajhøj wrote:
>> ... Assuming that we consider enum a class.
>
> It doesn't matter what you assume or consider, an enum is a class.

That is how JLS define it.

But some may consider class to be something with they class keyword.

Arne

[toc] | [prev] | [next] | [standalone]


#22712

FromLew <lewbloch@gmail.com>
Date2013-03-04 11:36 -0800
Message-ID<45aca1db-6f7f-49aa-b08f-42155dde73a3@googlegroups.com>
In reply to#22699
Arne Vajhøj wrote:
> Lew wrote:
>> Arne Vajhøj wrote:
>>> ... Assuming that we consider enum a class.
>>
>> It doesn't matter what you assume or consider, an enum is a class.
> 
> That is how JLS define it.

Q.E.D.

> But some may consider class to be something with they class keyword.

Some would be wrong.

Things are what they are. If you consider them not to be, you are wrong.

Some need to educate themselves.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22800

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-03-07 14:19 -0500
Message-ID<5138e82a$0$32107$14726298@news.sunsite.dk>
In reply to#22712
On 3/4/2013 2:36 PM, Lew wrote:
> Arne Vajhøj wrote:
>> Lew wrote:
>>> Arne Vajhøj wrote:
>>>> ... Assuming that we consider enum a class.
>>>
>>> It doesn't matter what you assume or consider, an enum is a class.
>>
>> That is how JLS define it.
>
> Q.E.D.
>
>> But some may consider class to be something with they class keyword.
>
> Some would be wrong.
>
> Things are what they are. If you consider them not to be, you are wrong.
>
> Some need to educate themselves.

I am a bit less dogmatic about such things.

I don't have a problem with people referring to actual Java syntax
instead of the explanation in English in JLS.

Arne

[toc] | [prev] | [next] | [standalone]


#22804

FromLew <lewbloch@gmail.com>
Date2013-03-07 13:34 -0800
Message-ID<1c615fe1-b9a7-4135-b724-cc72b5bd724b@googlegroups.com>
In reply to#22800
Arne Vajhøj wrote:
> Lew wrote:
>> Arne Vajhøj wrote:
>>> Lew wrote:
>>>> Arne Vajhøj wrote:
>>>>> ... Assuming that we consider enum a class.
> 
>>>> It doesn't matter what you assume or consider, an enum is a class.
>
>>> That is how JLS define it.
> 
>> Q.E.D.
> 
>>> But some may consider class to be something with they class keyword.
> 
> > Some would be wrong.

Of course, I'm wrong in the Enum does, indeed, use the 'class' keyword.

public abstract class Enum<E extends Enum<E>>
"This is the common base class of all Java language enumeration types."

>> Things are what they are. If you consider them not to be, you are wrong.
> 
>> Some need to educate themselves.
> 
> I am a bit less dogmatic about such things.
> 
> I don't have a problem with people referring to actual Java syntax
> instead of the explanation in English in JLS.

Then we agree, since the "actual Java syntax" is that it's a class.
http://docs.oracle.com/javase/7/docs/api/java/lang/Enum.html

And what you disingenuously call "the explanation in English in [the] JLS" is not an 
explanation but a specification, an entirely different beast, that normatively *defines* 
the terms.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22590

FromLew <lewbloch@gmail.com>
Date2013-02-27 12:24 -0800
Message-ID<2ece77fa-d125-4abd-bf44-e72f576f82aa@googlegroups.com>
In reply to#22564
markspace wrote:
> Robert Mark Bram wrote:
>> class A {

Notice that 'A' is not a top-level class.

>>      enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
>> }
>> A a = new A();
>>
>> When I try to execute this I get:
>>
>> The member enum Month can only be defined inside a top-level class or interface

And 'A' is not a top-level class. So make 'A' a top-level class.

> What's the name of the file this is defined in?  Is it A.java?  What 
> package is this defined in?
> 
> Ditto for the other file you tried.

Put the 'enum' in its own source file. Make it a top-level class itself.

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#22567

FromRobert Mark Bram <robertmarkbram@gmail.com>
Date2013-02-26 23:28 -0800
Message-ID<89914b7b-c35e-422d-9683-cd98c5b6cd78@googlegroups.com>
In reply to#22563
On Wednesday, 27 February 2013 16:52:10 UTC+11, Robert Mark Bram  wrote:
> Not sure if this is a bug or if I am going a bit crazy.. Am trying to do some quick testing of enums in an Eclipse jpage Scrapbook (using JDK 1.7.0_02, Win XP 64-bit, Eclipse Juno)
> 
> class A {
> 
>     enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
> 
> }
> 
> A a = new A();
> 
> When I try to execute this I get:
> 
> The member enum Month can only be defined inside a top-level class or interface

I believe the only way to do this is to move the enum itself out of the jpage into a new class. So I make the class like so:

package test;
public class Test {
   public enum Month {
      JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC;
   };
}

Then in the jpage:
1. right click and select "Set Imports"
2. click "Add Packages" and enter/select the test package.

Then my jpage will have the following code only:

Test.Month.valueOf("JAN");

[toc] | [prev] | [next] | [standalone]


#22568

Fromlipska the kat <"nospam at neversurrender dot co dot uk">
Date2013-02-27 09:50 +0000
Message-ID<Seudnalf3pNSS7DMnZ2dnUVZ7s-dnZ2d@bt.com>
In reply to#22563
On 27/02/13 05:52, Robert Mark Bram wrote:
> Hi All,
>
> Not sure if this is a bug or if I am going a bit crazy.. Am trying to do some quick testing of enums in an Eclipse jpage Scrapbook (using JDK 1.7.0_02, Win XP 64-bit, Eclipse Juno)

Hmm, this is irritating isn't it.
Judging by the replies you've got in the various user forums this either 
appears to be a bug or a limitation with the scrapbook

scrapbook pages are wrapped in a (presumably) top level class so you 
should apparently be able to do

enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};

Month m;

But this fails in Juno on Linux with JDK 1.7.03

Searching Eclipse bugzilla for 'Juno scrapbook' returns 0 bugs
Have you considered posting this as a potential bug

jeez, it's REALLY irritating.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.java.programmer


csiph-web