FAQ
Cover
\
Build
\
Source
\
Bugs
\
Reference
\
Libraries
\
Tools
The bugs database has moved
here
.
Bug 481 : preproc confused by "Xxxxx.class" syntax
Last modified: 2010-03-15 14:42
P
roject:
processing
trash
Version:
unspecified
Co
m
ponent:
android
book
core
libraries
pde
reference
tools
web
Status:
RESOLVED
Resolution:
FIXED -
Pr
i
ority:
P5
Severity:
normal
Platform
All
O
S:
All
Windows
Mac OS
Linux
Other
Reporter:
fjen
Assigned To:
fry
Attachment
Type
Created
Size
Actions
two example sketches
application/zip
2007-01-13 09:45
1.54 KB
Description
: Opened: 2007-01-13 09:42
processing 123, os-x 10.4, java 1.4.2
ran into it while trying to do some reflections with java.lang.reflect.Method in a sketch.
precompiler alters this (sketch-pde):
Class[] abc = new Class[]{Applet.class};
into this (temp-java):
Class[] abc = new Class[]{Applet.noLoop(); }
and gives this error:
Invalid type:70
/tmp/build3262.tmp/Temporary_683_1033.java:2:26:2:41: Syntax Error: "}" inserted to
complete ArrayInitializer
workaround is to have all reflection in a seperate .java-tab.
(i don't think many people are using reflect in sketches, but i thought i'd report it anyway)
F
Additional Comment
#1 From fjen 2007-01-13 09:45
edit
]
two example sketches
example 1: without noLoop()
example 2: with noLoop()
Additional Comment
#2 From fry 2007-01-13 09:51
actually it's not the reflection that's the issue it's that the preproc is
trying to figure out what mode you're in. when it sees "class" (the
"Applet.class" part, not "new Class[]") it thinks you're making a class
that extends PApplet, i.e. full Java mode.
Additional Comment
#3 From stefankreitmayer 2007-11-17 04:00
is there any workaround that avoids the .class syntax but still offers the
functionality? because it looks like i need it... thanks!
Additional Comment
#4 From fry 2007-11-17 04:02
have you tried getClass()?
Additional Comment
#5 From stefankreitmayer 2007-11-17 05:54
void setup()
{
String s;
if(s.getClass() == String.getClass())
println("yes");
}
this gives me the following error:
Semantic Error: The method "getClass" is not static, and cannot be accessed
in this static context.
how can i find out whether an object is of a specific class?
Additional Comment
#6 From fry 2007-11-17 06:56
ah, i see what you're trying to do. use either:
if (s instanceof String) {
// do something
}
or:
if (s.getClass().getName().equals("String")) {
// do something
}
the first method should be faster.
Additional Comment
#7 From eribeiro 2009-02-19 04:05
Use this
String aString = "";
Class[] abc = new Class[]{aString.getClass()};
instead of this
Class[] abc = new Class[]{String.class};
Additional Comment
#8 From MrFeinberg 2010-03-15 13:05
Cannot reproduce; please verify and close.
Additional Comment
#9 From fry 2010-03-15 14:42
confirmed fixed by jdf for 0180.