Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 355765

Summary: RuntimeException when values passed to mathLib.max don't match
Product: z_Archived Reporter: broy2
Component: EDTAssignee: Paul Harmon <pharmon>
Status: CLOSED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: mheitz, pfyu, pharmon, svihovec
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description broy2 CLA 2011-08-24 16:57:18 EDT
Build Identifier: 20110824

mySmallInt smallInt;
myInt int;
d = mathLib.max(mySmallInt,myInt);

Multiple markers at this line
- IWN.JavaGen.9998.e 32/633 Exception occurred: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
- IWN.JavaGen.9999.e 32/633 Stack Trace: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

Same is true with mathLib.min.

Reproducible: Always

Steps to Reproduce:
1.See above.
2.
3.
Comment 1 Brian Svihovec CLA 2011-09-13 23:02:42 EDT
This blocks the DataGrid widget.

A temporary workaround is to cast the parameters to a common type (e.g. as int)
Comment 2 Paul Harmon CLA 2011-09-15 08:56:27 EDT
This was fixed with the fix for BugĀ 356381
Comment 3 Brian Svihovec CLA 2011-09-15 16:03:33 EDT
The following test case fails:

function start()
		leftOver int;
		data any[];
		
		MathLib.max(1, data.getSize() - leftOver + 1);
	end	

with the following exception:

generating:client.test[client/test.egl]:(16)
org.eclipse.edt.mof.codegen.api.TemplateException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:432)
	at org.eclipse.edt.mof.codegen.api.TemplateContext.invoke(TemplateContext.java:263)
	at org.eclipse.edt.gen.javascript.templates.StatementTemplate.genStatementNoBraces(StatementTemplate.java:30)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:405)
	at org.eclipse.edt.mof.codegen.api.TemplateContext.invoke(TemplateContext.java:263)
	at org.eclipse.edt.gen.javascript.templates.FunctionTemplate.genFunctionBody(FunctionTemplate.java:40)
	at org.eclipse.edt.gen.javascriptdev.templates.FunctionTemplate.genFunctionBody(FunctionTemplate.java:36)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:405)
	at org.eclipse.edt.mof.codegen.api.TemplateContext.invoke(TemplateContext.java:263)
	at org.eclipse.edt.gen.javascript.templates.FunctionTemplate.genDeclaration(FunctionTemplate.java:34)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:405)
	at org.eclipse.edt.mof.codegen.api.TemplateContext.invoke(TemplateContext.java:263)
	at org.eclipse.edt.gen.javascript.templates.EGLClassTemplate.genFunction(EGLClassTemplate.java:304)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:407)
	at org.eclipse.edt.gen.EglContext.invoke(EglContext.java:408)
	at org.eclipse.edt.gen.javascript.templates.EGLClassTemplate.genFunctions(EGLClassTemplate.java:298)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:405)
	at org.eclipse.edt.gen.EglContext.invoke(EglContext.java:408)
	at org.eclipse.edt.gen.javascript.templates.EGLClassTemplate.genClassBody(EGLClassTemplate.java:123)
	at org.eclipse.edt.gen.javascriptdev.templates.EGLClassTemplate.genClassBody(EGLClassTemplate.java:27)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:405)
	at org.eclipse.edt.gen.EglContext.invoke(EglContext.java:408)
	at org.eclipse.edt.gen.javascript.templates.PartTemplate.genPart(PartTemplate.java:42)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:405)
	at org.eclipse.edt.gen.EglContext.invoke(EglContext.java:408)
	at org.eclipse.edt.gen.javascript.JavaScriptGenerator.generate(JavaScriptGenerator.java:80)
	at org.eclipse.edt.gen.AbstractGeneratorCommand.generate(AbstractGeneratorCommand.java:106)
	at org.eclipse.edt.gen.javascriptdev.ide.JavaScriptDevGenerator.generate(JavaScriptDevGenerator.java:29)
	at org.eclipse.edt.ide.core.internal.generation.GenerationQueue.invokeGenerators(GenerationQueue.java:264)
	at org.eclipse.edt.ide.core.internal.generation.GenerationQueue.generate(GenerationQueue.java:192)
	at org.eclipse.edt.ide.core.internal.generation.GenerationQueue.generate(GenerationQueue.java:145)
	at org.eclipse.edt.ide.core.internal.generation.AbstractGenerator.build(AbstractGenerator.java:49)
	at org.eclipse.edt.ide.core.internal.generation.GenerationBuilder.incrementalBuild(GenerationBuilder.java:106)
	at org.eclipse.edt.ide.core.internal.generation.GenerationBuilder.build(GenerationBuilder.java:65)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:203)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:255)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:258)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:311)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:343)
	at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:344)
	at org.eclipse.ui.actions.GlobalBuildAction$1.run(GlobalBuildAction.java:179)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.edt.mof.impl.AbstractVisitor.invokeVisit(AbstractVisitor.java:128)
	at org.eclipse.edt.mof.impl.AbstractVisitor.primVisit(AbstractVisitor.java:98)
	at org.eclipse.edt.mof.impl.InternalEObject.accept(InternalEObject.java:206)
	at org.eclipse.edt.mof.impl.InternalEObject.visitChildren(InternalEObject.java:230)
	at org.eclipse.edt.mof.impl.InternalEObject.accept(InternalEObject.java:208)
	at org.eclipse.edt.gen.ReorganizeCode.reorgCode(ReorganizeCode.java:65)
	at org.eclipse.edt.gen.javascript.templates.StatementBlockTemplate.processStatements(StatementBlockTemplate.java:48)
	at org.eclipse.edt.gen.javascriptdev.templates.StatementBlockTemplate.processStatements(StatementBlockTemplate.java:37)
	at org.eclipse.edt.gen.javascript.templates.StatementBlockTemplate.genStatementBodyNoBraces(StatementBlockTemplate.java:37)
	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 org.eclipse.edt.mof.codegen.api.TemplateContext.doInvoke(TemplateContext.java:405)
	... 73 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.GeneratedMethodAccessor70.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.edt.mof.impl.AbstractVisitor.invokeVisit(AbstractVisitor.java:125)
	... 86 more
Caused by: java.lang.RuntimeException: org.eclipse.edt.mof.egl.NoSuchFunctionError
	at org.eclipse.edt.mof.egl.impl.QualifiedFunctionInvocationImpl.getTarget(QualifiedFunctionInvocationImpl.java:53)
	at org.eclipse.edt.mof.egl.impl.QualifiedFunctionInvocationImpl.getTarget(QualifiedFunctionInvocationImpl.java:1)
	at org.eclipse.edt.gen.ReorganizeCode.processInvocationConstantParameters(ReorganizeCode.java:395)
	at org.eclipse.edt.gen.ReorganizeCode.processInvocation(ReorganizeCode.java:404)
	at org.eclipse.edt.gen.ReorganizeCode.visit(ReorganizeCode.java:379)
	... 90 more
Caused by: org.eclipse.edt.mof.egl.NoSuchFunctionError
	at org.eclipse.edt.mof.egl.impl.QualifiedFunctionInvocationImpl.resolveFunction(QualifiedFunctionInvocationImpl.java:123)
	at org.eclipse.edt.mof.egl.impl.QualifiedFunctionInvocationImpl.getTarget(QualifiedFunctionInvocationImpl.java:51)
	... 94 more
Comment 4 Paul Harmon CLA 2011-09-22 16:44:04 EDT
*** Bug 356381 has been marked as a duplicate of this bug. ***
Comment 5 Matt Heitz CLA 2011-09-22 17:26:04 EDT
We've decided to make some minor drastic changes to fix this problem.  Here's an email Paul Harmon sent around, describing what's going to change.


Team,

As mentioned in the meeting, I have modified the system parts to remove all definitions from egl.lang. This was done to remove the duplicate type definitions for String, Int and Boolean, as this was causing problems (as the EGLxxx types cannot be converted to the Exxx versions).

The following parts were moved from egl.lang into eglx.lang and renamed:

EglAny  ->  EAny
EglList   ->  EList
EGLNumber   ->  ENumber


Here is a list of all the other parts that were moved from egl.lang to eglx.lang:
//Annotations
Exception		
EventListener	
NativeType

//Types
AnyDelegate
AnyEnumeration
AnyRecord
AnyStruct
AnyText
AnyValue
NullType

//Exceptions
AnyException
InvalidArgumentException
InvalidIndexException
NullValueException
TypeCastException
DynamicAccessException
InvalidPatternException
InvocationException
NumericOverflowException


The following types have been eliminated:
EglBoolean
EGLInt
EGLString


If you have testcases that have an import for anything in egl.lang, you will need to either change this to eglx.lang, or remove it (in most cases, you wont need an import for the system parts).

I have updated the constants in MofConversion, but if you have references to "egl.lang" or new String[] {"egl", "lang"}, these need to be changed. Also, if there are reference to any of the 3 renamed types, or the 3 removed types, you will need to fix these as well. We will also need to change the name of some of our runtime classes to match the new names.

I have committed my changes to the branch named:  EglToEglxTypeChanges. You will need to load the following projects from this branch:

org.eclipse.edt.compiler
org.eclipse.edt.mof.egl

I have added a file in the root directory org.eclipse.edt.compiler named: PluginsInThisBranch.txt. As you add plugins to the branch, please update this document to include the plugin(s) added. This will provide a way for the team to know which plugins to load.

Please ping me as you run into problems or better yet, when you finish your changes. I will set up a meeting for tomorrow morning to discuss the progress.

Paul
Comment 6 pf yu CLA 2011-09-28 04:09:29 EDT
Here is a scenario to reproduce this issue again.

1. Check out project "org.eclipse.edt.eunit.test" from kan-cvs.
2. Add java generator to the project.
3. Clean the whole workspace.
4. Open "fvt.librarySupport.TestMathLib2Lib", the error exists in the function "testMax117()".
Comment 7 Brian Svihovec CLA 2011-09-28 09:47:53 EDT
The development of the language test framework is blocked by this defect, and this framework needs to be worked on before the end of this week.
Comment 8 Paul Harmon CLA 2011-09-28 11:39:05 EDT
I have made a change to TypeUtils and to ESmallFloat and EFloat (decimal->float is now a widen)
Comment 9 broy2 CLA 2011-09-29 11:18:55 EDT
Verified in 20110929 build.
Comment 10 Lisa Lasher CLA 2011-10-11 16:22:17 EDT
Closing this defect.