[jira] [Commented] (GROOVY-8044) MissingPropertyException for java style local variables

2017-01-14 Thread Jochen Theodorou (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15822761#comment-15822761
 ] 

Jochen Theodorou commented on GROOVY-8044:
--

that is a different expression. It is possible to support this and not support 
the other. Trying multiple interpretations is problematic, since that would 
mean a lot more class lookups and those are one of the most expensive 
operations during compilation. Following he Javastyle here solves the problem 
too, sine "de.my.package.lib.MyJavaFile theJavaFile = new 
de.my.package.lib.MyJavaFile();" will be recognized as class usages. Changing 
myJavaFile to a class if there is no valid property/method on the other hand is 
impossible in nonstatic Groovy, since they could always come into existence at 
runtime.

> MissingPropertyException for java style local variables
> ---
>
> Key: GROOVY-8044
> URL: https://issues.apache.org/jira/browse/GROOVY-8044
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.7
> Environment: KUbuntu16.10 but also present on Windows 7, Mac OS 10.9.5
>Reporter: MeFisto94
>  Labels: newbie
>
> Hey Guys,
> First off: Sorry if this is a fault on my side but I highly doubt it.
> I am using Groovy to compile java and groovy files on the fly to use them as 
> regular Class instances.
> I use my implementation of GroovyResourceLoader but I can confirm that it 
> works, since if I break it purposely, Groovy complains about unknown class 
> definitions during compile-time (of the script).
> So what happens is that I can successfully instantiate the freshly loaded 
> class but as soon as I call a method which has a java style definition, it 
> crashes during runtime.
> So a few examples:
> {code}
> @Override
> public URL loadGroovySource(String fileName) throws MalformedURLException 
> {
> if (fileName.startsWith("de.my.packages")) {
> String className = 
> fileName.substring("de.my.packages".length()).replace('.', '/');
> 
> for (String extension : new String[] { ".java", ".groovy" }) {
> File classFile = new File(basicPath, className + extension);
> if (classFile.exists()) {
> System.out.println("FOUND " + 
> classFile.getAbsolutePath());
> return classFile.toURI().toURL();
> }
> }
> }
> 
> return null;
> }
> {code}
> Please ignore the fact that the variable names are misleading. Actually 
> fileName should be className and className should be fileName...
> Now the code to get those Classes:
> {code}
> groovyClassLoader = new 
> GroovyClassLoader(Thread.currentThread().getContextClassLoader());
> groovyClassLoader.setResourceLoader(new CustomGroovyResourceLoader(current));
> File f = new File(filePath);
> if (!f.exists()) {
>   throw new FileNotFoundException(filePath);
> }   
> return groovyClassLoader.parseClass(f);
> {code}
> The error now is:
> {code}
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> groovy.lang.MissingPropertyException: No such property: de for class: 
> de.my.package.script2
> Possible solutions: name
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
> at 
> org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:87)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
> at de.my.package.script2.getInterfaceVersion(script2.java:27)
> at java.lang.Thread.run(Thread.java:745)
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> {code}
> Now my actual script file looks like this at that line:
> {code}
> de.my.package.lib.myJavaFile theJavaFile = new de.my.package.lib.myJavaFile();
> {code}
> This means that for some reason during runtime it quits after the . of de.
> Initially the code looked like this though:
> {code}
> myJavaFile theJavaFile = new myJavaFile();
> {code}
> This lead to the same Exception, I tried specifying the correct package 
> manually to rule out some errors with the resolution (Groovy definately knows 
> the myJavaFile class because parseClass would fail).
> Please note that my package isn't really "de.my.package", since package is a 
> reserved keyword but I had to edit it out.
> What does work is "def theJavaFile = new myJavaFile();".
> What ALSO works is the java style definition for files available through the 
> classpath (e.g. conventional code, anything from java.lang, ...)
> Am I probably missing some compilersettings to allow java compability?
> Thanks in Advan

[jira] [Commented] (GROOVY-8044) MissingPropertyException for java style local variables

2017-01-13 Thread MeFisto94 (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15822144#comment-15822144
 ] 

MeFisto94 commented on GROOVY-8044:
---

Hmm, but wouldn't that defeat (old c style, though) code like this:

{code}
char c
while (c = readChar()) {
}
{code}

I am neither experienced with parsers nor familar with the groovy sourcecode, 
but:
For the myJavaFile theJavaFile being interpreted like a method call though, 
wouldn't it be possible to try multiple interpretions.
Like: a) Property is not found, b) myJavaFile is no (static) method either but 
a class, so that has to be an assignment.

Same actually with the other issue: When myJavaFile is no valid property/method 
but a class, change the meaning of the whole line.
But as I said, I have no clue if this is within the scope of possible things. 
For now I can live with that.

> MissingPropertyException for java style local variables
> ---
>
> Key: GROOVY-8044
> URL: https://issues.apache.org/jira/browse/GROOVY-8044
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.7
> Environment: KUbuntu16.10 but also present on Windows 7, Mac OS 10.9.5
>Reporter: MeFisto94
>  Labels: newbie
>
> Hey Guys,
> First off: Sorry if this is a fault on my side but I highly doubt it.
> I am using Groovy to compile java and groovy files on the fly to use them as 
> regular Class instances.
> I use my implementation of GroovyResourceLoader but I can confirm that it 
> works, since if I break it purposely, Groovy complains about unknown class 
> definitions during compile-time (of the script).
> So what happens is that I can successfully instantiate the freshly loaded 
> class but as soon as I call a method which has a java style definition, it 
> crashes during runtime.
> So a few examples:
> {code}
> @Override
> public URL loadGroovySource(String fileName) throws MalformedURLException 
> {
> if (fileName.startsWith("de.my.packages")) {
> String className = 
> fileName.substring("de.my.packages".length()).replace('.', '/');
> 
> for (String extension : new String[] { ".java", ".groovy" }) {
> File classFile = new File(basicPath, className + extension);
> if (classFile.exists()) {
> System.out.println("FOUND " + 
> classFile.getAbsolutePath());
> return classFile.toURI().toURL();
> }
> }
> }
> 
> return null;
> }
> {code}
> Please ignore the fact that the variable names are misleading. Actually 
> fileName should be className and className should be fileName...
> Now the code to get those Classes:
> {code}
> groovyClassLoader = new 
> GroovyClassLoader(Thread.currentThread().getContextClassLoader());
> groovyClassLoader.setResourceLoader(new CustomGroovyResourceLoader(current));
> File f = new File(filePath);
> if (!f.exists()) {
>   throw new FileNotFoundException(filePath);
> }   
> return groovyClassLoader.parseClass(f);
> {code}
> The error now is:
> {code}
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> groovy.lang.MissingPropertyException: No such property: de for class: 
> de.my.package.script2
> Possible solutions: name
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
> at 
> org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:87)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
> at de.my.package.script2.getInterfaceVersion(script2.java:27)
> at java.lang.Thread.run(Thread.java:745)
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> {code}
> Now my actual script file looks like this at that line:
> {code}
> de.my.package.lib.myJavaFile theJavaFile = new de.my.package.lib.myJavaFile();
> {code}
> This means that for some reason during runtime it quits after the . of de.
> Initially the code looked like this though:
> {code}
> myJavaFile theJavaFile = new myJavaFile();
> {code}
> This lead to the same Exception, I tried specifying the correct package 
> manually to rule out some errors with the resolution (Groovy definately knows 
> the myJavaFile class because parseClass would fail).
> Please note that my package isn't really "de.my.package", since package is a 
> reserved keyword but I had to edit it out.
> What does work is "def theJavaFile = new myJavaFile();".
> What ALSO works is the java style definition for files available through the 
> classpath (e.g. conventional code, anything from java.lang, ...)
> Am I probably missi

[jira] [Commented] (GROOVY-8044) MissingPropertyException for java style local variables

2017-01-13 Thread Jochen Theodorou (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15821790#comment-15821790
 ] 

Jochen Theodorou commented on GROOVY-8044:
--

it is not so easy to explain, it is an issue of the grammar. 
"de.my.package.lib.myJavaFile theJavaFile = new de.my.package.lib.myJavaFile()" 
is in Groovy a valid method call. It asks the property de, for a property my, 
for a property package, for a propery lib for a method myJavaFile and executes 
it with a variable of name theJavaFile, to which it did = new 
de.my.package.lib.myJavaFile() before. And in this new-instance expression 
Groovy knows it must be a class  Your special case with assignment might be 
solvable though if we disallow the assignment in a method call expression. So 
maybe we can solve your issue by removing a rule in the grammar. Something like 
"de.my.package.lib.myJavaFile theJavaFile" would stay problematic though.

> MissingPropertyException for java style local variables
> ---
>
> Key: GROOVY-8044
> URL: https://issues.apache.org/jira/browse/GROOVY-8044
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.7
> Environment: KUbuntu16.10 but also present on Windows 7, Mac OS 10.9.5
>Reporter: MeFisto94
>  Labels: newbie
>
> Hey Guys,
> First off: Sorry if this is a fault on my side but I highly doubt it.
> I am using Groovy to compile java and groovy files on the fly to use them as 
> regular Class instances.
> I use my implementation of GroovyResourceLoader but I can confirm that it 
> works, since if I break it purposely, Groovy complains about unknown class 
> definitions during compile-time (of the script).
> So what happens is that I can successfully instantiate the freshly loaded 
> class but as soon as I call a method which has a java style definition, it 
> crashes during runtime.
> So a few examples:
> {code}
> @Override
> public URL loadGroovySource(String fileName) throws MalformedURLException 
> {
> if (fileName.startsWith("de.my.packages")) {
> String className = 
> fileName.substring("de.my.packages".length()).replace('.', '/');
> 
> for (String extension : new String[] { ".java", ".groovy" }) {
> File classFile = new File(basicPath, className + extension);
> if (classFile.exists()) {
> System.out.println("FOUND " + 
> classFile.getAbsolutePath());
> return classFile.toURI().toURL();
> }
> }
> }
> 
> return null;
> }
> {code}
> Please ignore the fact that the variable names are misleading. Actually 
> fileName should be className and className should be fileName...
> Now the code to get those Classes:
> {code}
> groovyClassLoader = new 
> GroovyClassLoader(Thread.currentThread().getContextClassLoader());
> groovyClassLoader.setResourceLoader(new CustomGroovyResourceLoader(current));
> File f = new File(filePath);
> if (!f.exists()) {
>   throw new FileNotFoundException(filePath);
> }   
> return groovyClassLoader.parseClass(f);
> {code}
> The error now is:
> {code}
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> groovy.lang.MissingPropertyException: No such property: de for class: 
> de.my.package.script2
> Possible solutions: name
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
> at 
> org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:87)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
> at de.my.package.script2.getInterfaceVersion(script2.java:27)
> at java.lang.Thread.run(Thread.java:745)
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> {code}
> Now my actual script file looks like this at that line:
> {code}
> de.my.package.lib.myJavaFile theJavaFile = new de.my.package.lib.myJavaFile();
> {code}
> This means that for some reason during runtime it quits after the . of de.
> Initially the code looked like this though:
> {code}
> myJavaFile theJavaFile = new myJavaFile();
> {code}
> This lead to the same Exception, I tried specifying the correct package 
> manually to rule out some errors with the resolution (Groovy definately knows 
> the myJavaFile class because parseClass would fail).
> Please note that my package isn't really "de.my.package", since package is a 
> reserved keyword but I had to edit it out.
> What does work is "def theJavaFile = new myJavaFile();".
> What ALSO works is the java style definition for files available through the 
> classpath (e.g. co

[jira] [Commented] (GROOVY-8044) MissingPropertyException for java style local variables

2017-01-13 Thread MeFisto94 (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15821735#comment-15821735
 ] 

MeFisto94 commented on GROOVY-8044:
---

That definitely fixes it. Actually it is two issues:
A) If you specify the package, it stops after the dot after de. 
B) If you don't specify the package, it seems to ignore the "myJavaFile" and 
thinks the variable name would be the property.

What does "cannot handle lowercase class names very well" actually mean?
Is this a design flaw of some sort so wont Groovy ever be able to handle them 
or is this rather a bug?

> MissingPropertyException for java style local variables
> ---
>
> Key: GROOVY-8044
> URL: https://issues.apache.org/jira/browse/GROOVY-8044
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.7
> Environment: KUbuntu16.10 but also present on Windows 7, Mac OS 10.9.5
>Reporter: MeFisto94
>  Labels: newbie
>
> Hey Guys,
> First off: Sorry if this is a fault on my side but I highly doubt it.
> I am using Groovy to compile java and groovy files on the fly to use them as 
> regular Class instances.
> I use my implementation of GroovyResourceLoader but I can confirm that it 
> works, since if I break it purposely, Groovy complains about unknown class 
> definitions during compile-time (of the script).
> So what happens is that I can successfully instantiate the freshly loaded 
> class but as soon as I call a method which has a java style definition, it 
> crashes during runtime.
> So a few examples:
> {code}
> @Override
> public URL loadGroovySource(String fileName) throws MalformedURLException 
> {
> if (fileName.startsWith("de.my.packages")) {
> String className = 
> fileName.substring("de.my.packages".length()).replace('.', '/');
> 
> for (String extension : new String[] { ".java", ".groovy" }) {
> File classFile = new File(basicPath, className + extension);
> if (classFile.exists()) {
> System.out.println("FOUND " + 
> classFile.getAbsolutePath());
> return classFile.toURI().toURL();
> }
> }
> }
> 
> return null;
> }
> {code}
> Please ignore the fact that the variable names are misleading. Actually 
> fileName should be className and className should be fileName...
> Now the code to get those Classes:
> {code}
> groovyClassLoader = new 
> GroovyClassLoader(Thread.currentThread().getContextClassLoader());
> groovyClassLoader.setResourceLoader(new CustomGroovyResourceLoader(current));
> File f = new File(filePath);
> if (!f.exists()) {
>   throw new FileNotFoundException(filePath);
> }   
> return groovyClassLoader.parseClass(f);
> {code}
> The error now is:
> {code}
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> groovy.lang.MissingPropertyException: No such property: de for class: 
> de.my.package.script2
> Possible solutions: name
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
> at 
> org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:87)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
> at de.my.package.script2.getInterfaceVersion(script2.java:27)
> at java.lang.Thread.run(Thread.java:745)
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> {code}
> Now my actual script file looks like this at that line:
> {code}
> de.my.package.lib.myJavaFile theJavaFile = new de.my.package.lib.myJavaFile();
> {code}
> This means that for some reason during runtime it quits after the . of de.
> Initially the code looked like this though:
> {code}
> myJavaFile theJavaFile = new myJavaFile();
> {code}
> This lead to the same Exception, I tried specifying the correct package 
> manually to rule out some errors with the resolution (Groovy definately knows 
> the myJavaFile class because parseClass would fail).
> Please note that my package isn't really "de.my.package", since package is a 
> reserved keyword but I had to edit it out.
> What does work is "def theJavaFile = new myJavaFile();".
> What ALSO works is the java style definition for files available through the 
> classpath (e.g. conventional code, anything from java.lang, ...)
> Am I probably missing some compilersettings to allow java compability?
> Thanks in Advance



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-8044) MissingPropertyException for java style local variables

2017-01-11 Thread Jochen Theodorou (JIRA)

[ 
https://issues.apache.org/jira/browse/GROOVY-8044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15820294#comment-15820294
 ] 

Jochen Theodorou commented on GROOVY-8044:
--

can you do {code:Java}
import de.my.package.lib.myJavaFile as JavaFile
JavaFile theJavaFile = new JavaFile()
{code}
reason being that in those declarations Groovy cannot handle lowercase class 
names very well

> MissingPropertyException for java style local variables
> ---
>
> Key: GROOVY-8044
> URL: https://issues.apache.org/jira/browse/GROOVY-8044
> Project: Groovy
>  Issue Type: Bug
>  Components: groovy-runtime
>Affects Versions: 2.4.7
> Environment: KUbuntu16.10 but also present on Windows 7, Mac OS 10.9.5
>Reporter: MeFisto94
>  Labels: newbie
>
> Hey Guys,
> First off: Sorry if this is a fault on my side but I highly doubt it.
> I am using Groovy to compile java and groovy files on the fly to use them as 
> regular Class instances.
> I use my implementation of GroovyResourceLoader but I can confirm that it 
> works, since if I break it purposely, Groovy complains about unknown class 
> definitions during compile-time (of the script).
> So what happens is that I can successfully instantiate the freshly loaded 
> class but as soon as I call a method which has a java style definition, it 
> crashes during runtime.
> So a few examples:
> {code}
> @Override
> public URL loadGroovySource(String fileName) throws MalformedURLException 
> {
> if (fileName.startsWith("de.my.packages")) {
> String className = 
> fileName.substring("de.my.packages".length()).replace('.', '/');
> 
> for (String extension : new String[] { ".java", ".groovy" }) {
> File classFile = new File(basicPath, className + extension);
> if (classFile.exists()) {
> System.out.println("FOUND " + 
> classFile.getAbsolutePath());
> return classFile.toURI().toURL();
> }
> }
> }
> 
> return null;
> }
> {code}
> Please ignore the fact that the variable names are misleading. Actually 
> fileName should be className and className should be fileName...
> Now the code to get those Classes:
> {code}
> groovyClassLoader = new 
> GroovyClassLoader(Thread.currentThread().getContextClassLoader());
> groovyClassLoader.setResourceLoader(new CustomGroovyResourceLoader(current));
> File f = new File(filePath);
> if (!f.exists()) {
>   throw new FileNotFoundException(filePath);
> }   
> return groovyClassLoader.parseClass(f);
> {code}
> The error now is:
> {code}
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> groovy.lang.MissingPropertyException: No such property: de for class: 
> de.my.package.script2
> Possible solutions: name
> at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
> at 
> org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:87)
> at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
> at de.my.package.script2.getInterfaceVersion(script2.java:27)
> at java.lang.Thread.run(Thread.java:745)
> No such property: de for class: de.my.package.script2
> Possible solutions: name
> {code}
> Now my actual script file looks like this at that line:
> {code}
> de.my.package.lib.myJavaFile theJavaFile = new de.my.package.lib.myJavaFile();
> {code}
> This means that for some reason during runtime it quits after the . of de.
> Initially the code looked like this though:
> {code}
> myJavaFile theJavaFile = new myJavaFile();
> {code}
> This lead to the same Exception, I tried specifying the correct package 
> manually to rule out some errors with the resolution (Groovy definately knows 
> the myJavaFile class because parseClass would fail).
> Please note that my package isn't really "de.my.package", since package is a 
> reserved keyword but I had to edit it out.
> What does work is "def theJavaFile = new myJavaFile();".
> What ALSO works is the java style definition for files available through the 
> classpath (e.g. conventional code, anything from java.lang, ...)
> Am I probably missing some compilersettings to allow java compability?
> Thanks in Advance



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)