DevBoost / JaMoPP

JaMoPP can parse Java source and byte code into EMF-based models and vice versa. It preserves source formatting and can be used for code analysis and refactoring.
17 stars 18 forks source link

error when run atl uml2atl #7

Closed lengoccanh84 closed 11 years ago

lengoccanh84 commented 11 years ago

I see atl has changed and different from content on website. When I build atl file, it generate class with incorrect class structure: class Address { protected //@classifiers[name='List'] contact; }

Please help urgent

mirkoseifert commented 11 years ago

Can you please give some more details on what you're trying to do? With that little information we can't provide help.

lengoccanh84 commented 11 years ago

jamopp Hi mirko

Please see red section in attached image. There are 3 problems: 1.When I run uml2java.atl, in console it shows many warning eg: Metamodel contains several classifiers with same name: Annotable Metamodel contains several classifiers with same name: AnnotationInstance Metamodel contains several classifiers with same name: AnnotationParameter Metamodel contains several classifiers with same name: SingleAnnotationParameter Metamodel contains several classifiers with same name: AnnotationParameterList ......................................................................................................................

  1. And it generate java class with wrong format: protected //@classifiers[name='String'] forename; protected //@classifiers[name='String'] surname;

3.It doesnot add function content from file ClassDiagram.uml.Person.print.javabehavior import de.tudresden.contact_management.*;

public void print () { Person p = this; String fullName = p.forename + " " + p.surname; String msg = "My name is " + fullName + "."; System.out.println(msg); } to method class Person extends Contact { protected //@classifiers[name='String'] forename; protected //@classifiers[name='String'] surname; public void print() { { //i dont see content added here........................ } }

I already install atl, jamopp in eclipse Please help

jjohannes commented 11 years ago

Could you attach an example project and state which Eclipse/ATL/JaMoPP versions you are using?

lengoccanh84 commented 11 years ago

Could you suggest me the best eclipse version, ATL, JaMoPP version and where to download? I download example project from github https://github.com/DevBoost/JaMoPP When I tried with three version of Eclipse, it showed the same issue.

Here are there version of Eclipse and JaMoPP, ATL version:

Eclipse Standard/SDK Version: Kepler Service Release 1 Build id: 20130919-0819 ATL 3.3.1 EMFText 1.4.1 JaMoPP 1.4.0

Version: Indigo Service Release 2 Build id: 20120216-1857 ATL 3.3.1 EMFText 1.4.1 JaMoPP 1.4.0

Eclipse Modeling Tools Version: Helios Service Release 2 Build id: 20110218-0911 ATL 3.3.1 JaMoPP 1.4.0

I see that atl source( eg: rule Property) on github is different from atlsource example on http://www.jamopp.org/index.php/JaMoPP_Applications_ATL

Other issue is when I create attribute of class and set type is Interger/Boolean. It show error: org.eclipse.m2m.atl.engine.emfvm.VMException: org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl cannot be cast to org.emftext.language.java.classifiers.Classifier at applyProperty#67(uml2java.atl[55:3-55:42]) local variables: self=uml2java : ASMModule, link=TransientLink {rule = Property, sourceElements = {umlProperty = org.eclipse.uml2.uml.internal.impl.PropertyImpl@1b73ecd (name: surname, visibility: ) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (aggregation: none, isDerived: false, isDerivedUnion: false, isID: false)}, targetElements = {typeRef2 = org.emftext.language.java.types.impl.ClassifierReferenceImpl@15b5f5a, javaField = org.emftext.language.java.members.impl.FieldImpl@1d13b8a (name: surname), typeRef1 = org.emftext.language.java.types.impl.ClassifierReferenceImpl@19c218e, protected = org.emftext.language.java.modifiers.impl.ProtectedImpl@15f0c1a, voidType = org.emftext.language.java.types.impl.VoidImpl@113a7ab, typeArgument = org.emftext.language.java.generics.impl.QualifiedTypeArgumentImpl@1650172}, variables = {}}, umlProperty=IN!surname, javaField=OUT!surname, protected=OUT!, voidType=OUT!, typeRef1=OUT!, typeArgument=OUT!, typeRef2=OUT! at __exec#18(uml2java.atl) local variables: self=uml2java : ASMModule, e=TransientLink {rule = Property, sourceElements = {umlProperty = org.eclipse.uml2.uml.internal.impl.PropertyImpl@1b73ecd (name: surname, visibility: ) (isLeaf: false) (isStatic: false) (isOrdered: false, isUnique: true, isReadOnly: false) (aggregation: none, isDerived: false, isDerivedUnion: false, isID: false)}, targetElements = {typeRef2 = org.emftext.language.java.types.impl.ClassifierReferenceImpl@15b5f5a, javaField = org.emftext.language.java.members.impl.FieldImpl@1d13b8a (name: surname), typeRef1 = org.emftext.language.java.types.impl.ClassifierReferenceImpl@19c218e, protected = org.emftext.language.java.modifiers.impl.ProtectedImpl@15f0c1a, voidType = org.emftext.language.java.types.impl.VoidImpl@113a7ab, typeArgument = org.emftext.language.java.generics.impl.QualifiedTypeArgumentImpl@1650172}, variables = {}} at main#24(uml2java.atl) local variables: self=uml2java : ASMModule

jjohannes commented 11 years ago

The warnings are not a problem (I do not know why they appear).

The problem was that java.lang and java.util packages need to be defined as input models to make classes like String or List available. This was configured in the build.xml (which can only be used with am3 ant tasks) but not the launch config. I added this to the launch config as well.

The second issue (org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl cannot be cast to org.emftext.language.java.classifiers.Classifier) appears, because the transformation is far from complete. It is only a very minimal example of giving an idea of how UML2Java with ATL and JaMoPP can work.

The error means that some UML type is not translated into a corresponding Java type. To fix that, you need to extend the transformation script.

lengoccanh84 commented 11 years ago

It seem that the changed code does not resolve problem. It still shows: protected //@classifiers[name='String'] forename; protected //@classifiers[name='String'] surname;