views:

380

answers:

2

For instance, is the following legal

public class Foo {
  private native int bar;
}
+7  A: 

No. You could've tried this in Eclipse and it would've complained.

Bozho
As if Eclipse never complained about something that wasn't actually legal..
Laurence Gonsalves
Give an example, would you? I can recall NetBeans doing it, but haven't caught Eclipse.
Bozho
Eclipse might warn you, or might show a warning as an error if you've configured it to do so ... but this is all up to you configuring Eclipse to be overly cautious.
matt b
Replace "Eclipse" by "javac" and the answer is a bit more robust.
BalusC
yes, Matt, but do you think the author of the question has configured his Eclipse? :)
Bozho
+1  A: 

Sooner or later the folks out there will start asking on SO where their car keys are on.

And this is everything but fun. I mean, come on, writing the above code in Notepad, saving it as a .java file* and running javac over it should have taken less than posting over here.

* Enclose the name of the file between " as in "OurFirstEverNotepadJavaUnitTheGreatNativeTest.java", otherwise you'll get a (kernel) panic attack once you'll see it gets saved as .java.txt

Marius Burz