Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » NPE using OCL ValidationVisitor
NPE using OCL ValidationVisitor [message #54185] Wed, 23 April 2008 06:48 Go to next message
Adolfo Sanchez-Barbudo Herrera is currently offline Adolfo Sanchez-Barbudo Herrera
Messages: 253
Registered: July 2009
Senior Member
Hi Christian,

Validating a variableExp which doesn't have a referredVariable, throws
an exception. In fact, it's a problem of the ToStringVisitor, which is
used when toString() is invoked in a VariableExp with out referredVariable.

the ToStringVisitior.visitVariablExp method should check that the
referredVariable from the variableExp is not null before getting its name.

If you agree, I could arise a bugzilla with a patch...

the trace:
java.lang.NullPointerException
at
org.eclipse.ocl.util.ToStringVisitor.visitVariableExp(ToStri ngVisitor.java:203)
at
org.eclipse.ocl.util.ToStringVisitor.visitVariableExp(ToStri ngVisitor.java:1)
at
org.eclipse.ocl.ecore.impl.VariableExpImpl.accept(VariableEx pImpl.java:233)
at
org.eclipse.ocl.ecore.impl.OCLExpressionImpl.toString(OCLExp ressionImpl.java:317)
at
org.eclipse.ocl.ecore.impl.VariableExpImpl.toString(Variable ExpImpl.java:225)
at
org.eclipse.ocl.parser.ValidationVisitor.visitVariableExp(Va lidationVisitor.java:320)
at
org.eclipse.ocl.parser.ValidationVisitor.visitVariableExp(Va lidationVisitor.java:1)
at
org.eclipse.ocl.ecore.impl.VariableExpImpl.accept(VariableEx pImpl.java:233)
at
org.eclipse.ocl.parser.ValidationVisitor.visitOperationCallE xp(ValidationVisitor.java:196)
at
org.eclipse.ocl.parser.ValidationVisitor.visitOperationCallE xp(ValidationVisitor.java:1)
at
org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(Opera tionCallExpImpl.java:357)
at
org.eclipse.gmt.umlx.eqvto.cst.environment.QVToEnvironment.o clValidation(QVToEnvironment.java:391)
at
org.eclipse.gmt.umlx.eqvto.cst.environment.QVToEnvironment.o clValidation(QVToEnvironment.java:400)
at
org.eclipse.gmt.umlx.eqvto.cst.environment.QVToEnvironment.o clValidation(QVToEnvironment.java:400)
at
org.eclipse.gmt.umlx.eqvto.cst.environment.QVToEnvironment.o clValidation(QVToEnvironment.java:400)
at
org.eclipse.gmt.umlx.eqvto.cst.environment.QVToEnvironment.o clValidation(QVToEnvironment.java:400)
at
org.eclipse.gmt.umlx.eqvto.cst.environment.QVToEnvironment.v alidate(QVToEnvironment.java:382)
at
org.eclipse.gmt.umlx.eqvto.cst.environment.QVToTopLevelEnvir onment.validate(QVToTopLevelEnvironment.java:46)
at
org.eclipse.gmt.umlx.eqvto.tests.parser.AbstractQVToTestCase .parserTest(AbstractQVToTestCase.java:108)
at
org.eclipse.gmt.umlx.eqvto.tests.parser.QVToParseTests.testP arseEQVTOperational_ImperativeIterateExp(QVToParseTests.java :214)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestRefer ence.run(JUnit3TestReference.java:130)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main( RemoteTestRunner.java:196)



Cheers,
Adolfo.
Re: NPE using OCL ValidationVisitor [message #54313 is a reply to message #54185] Wed, 23 April 2008 14:27 Go to previous message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Adolfo,

Of course, I agree! NPEs in validation of an expression are bugs, except
only in the case that the input expression is a null pointer (which would
be a silly input).

cW

Adolfo Sánchez-Barbudo Herrera wrote:

> Hi Christian,
>
> Validating a variableExp which doesn't have a referredVariable, throws
> an exception. In fact, it's a problem of the ToStringVisitor, which is
> used when toString() is invoked in a VariableExp with out
> referredVariable.
>
> the ToStringVisitior.visitVariablExp method should check that the
> referredVariable from the variableExp is not null before getting its name.
>
> If you agree, I could arise a bugzilla with a patch...

-----8<-----
Previous Topic:RE: OCL Def Operations & Attributes
Next Topic:[Announce] MDT OCL 1.2.0 I200804231800 is available
Goto Forum:
  


Current Time: Wed Jul 23 03:54:07 EDT 2014

Powered by FUDForum. Page generated in 0.02244 seconds