Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Java metamodel #276

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ab95c39
- Replaced dependencies to old Java-MM with new MM
tschilpp Jun 5, 2023
74595ae
- Replaced old dependencies
tschilpp Jul 3, 2023
bc3d34b
- Replaced JavaClasspath.registerClassifierJar(URI, String) with
tschilpp Jul 3, 2023
d6cf521
- JavaToUmlClassifier
tschilpp Jul 10, 2023
b8a9e4c
- Removed unused imports
tschilpp Jul 21, 2023
fae3927
- Removed unused <nature> tags
tschilpp Aug 11, 2023
96afda8
- Java2PcmClassifier.reactions
tschilpp Aug 18, 2023
fc2683a
- Every time a constructor is created a block for this constructor is
tschilpp Aug 18, 2023
04009ea
- An empty statement is now being added when creating an interface
tschilpp Aug 18, 2023
b62a682
- JavaMemberAndParameterUtil.xtend
tschilpp Aug 18, 2023
3eaa7b8
- Added checks to every creation/update of a class/interface method to
tschilpp Aug 18, 2023
aa74aa7
- JavaToUmlClassifier.reactions
tschilpp Aug 18, 2023
ea81511
- Added missing statements to add an empty statement when creating types
tschilpp Aug 25, 2023
bec9dbd
- Added missing statements to add an empty statement when creating types
tschilpp Aug 25, 2023
39bcbfa
Merge branch 'main' of https://github.com/tschilpp/Vitruv-CaseStudies…
tschilpp Sep 1, 2023
972e36a
Merge branch 'wip' of https://git.scc.kit.edu/i43/stud/praktika/sose2…
tschilpp Sep 1, 2023
fce0bf9
- Removed all temporary files created by the Maven
tschilpp Sep 2, 2023
a3b3f4b
- Removed all unnecessary JaMoPP-bundle imports
tschilpp Sep 2, 2023
e588864
Re-add old metamodel and used utils and backported them to the old me…
TomWerm Sep 6, 2023
40a1803
Merge branch 'main' into new-java-metamodel
TomWerm Sep 6, 2023
7c873ae
Update MANIFEST.MF
TomWerm Sep 8, 2023
7c5e23b
- JavaToUmlClassMethodTest.testCreateConstructor():
tschilpp Sep 10, 2023
411b4da
Merge branch 'main' into new-java-metamodel
TomWerm Sep 21, 2023
ab08e58
Update MANIFEST.MF
TomWerm Sep 21, 2023
d35783f
Merge remote-tracking branch 'Vitruv/Vitruv-CaseStudies/main' into ne…
HansMartinA Sep 22, 2023
4b3ca61
Merge remote-tracking branch 'origin/wip' into new-java-metamodel
HansMartinA Sep 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ xtend-gen/
# Maven
target/
.mvn/wrapper/maven-wrapper.jar
*.polyglot.*

# Custom
EvaluationData
*.DS_Store
*.polyglot
*.pom.tycho
*.pom.tycho
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Require-Bundle: tools.vitruv.framework.applications,
org.eclipse.uml2.uml;visibility:=reexport,
org.emftext.language.java;visibility:=reexport,
edu.kit.ipd.sdq.activextendannotations,
tools.vitruv.applications.util.temporary,
edu.kit.ipd.sdq.commons.util.emf
edu.kit.ipd.sdq.commons.util.emf,
tools.vitruv.applications.cbs.testutils
Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: tools.vitruv.applications.cbs.commonalities
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import tools.vitruv.applications.cbs.commonalities.oo.Visibility
import static com.google.common.base.Preconditions.*
import static tools.vitruv.dsls.commonalities.runtime.helper.XtendAssertHelper.*

import static extension tools.vitruv.applications.util.temporary.java.JavaModifierUtil.*
import static extension tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaModifierUtil.*

/**
* Helper class for the mapping between Java's visibility modifiers and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package tools.vitruv.applications.cbs.commonalities.java.operators

import org.apache.log4j.Logger
import org.emftext.language.java.JavaUniquePathConstructor
import org.emftext.language.java.containers.CompilationUnit
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.attribute.AbstractAttributeMappingOperator
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.attribute.AttributeMappingOperator
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.attribute.AttributeType
import tools.vitruv.dsls.reactions.runtime.state.ReactionExecutionState

import static com.google.common.base.Preconditions.*
import org.emftext.language.java.JavaUniquePathConstructor

// CompilationUnit name schema: '<dot-separated-namespaces>.<fileName/classifierName>.java'
@AttributeMappingOperator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package tools.vitruv.applications.cbs.commonalities.java.operators

import org.apache.log4j.Logger
import org.eclipse.emf.ecore.EObject
import org.emftext.language.java.JavaUniquePathConstructor
import org.emftext.language.java.commons.NamespaceAwareElement
import org.emftext.language.java.containers.CompilationUnit
import org.emftext.language.java.containers.ContainersPackage
import org.emftext.language.java.containers.Package
import tools.vitruv.applications.util.temporary.java.JavaPersistenceHelper
import tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaPersistenceHelper
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.reference.AbstractReferenceMappingOperator
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.reference.ReferenceMappingOperator
import tools.vitruv.dsls.reactions.runtime.state.ReactionExecutionState

import static com.google.common.base.Preconditions.*
import static tools.vitruv.dsls.commonalities.runtime.helper.XtendAssertHelper.*
import static extension tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaContainerAndClassifierUtil.*

import static extension tools.vitruv.dsls.commonalities.runtime.helper.IntermediateModelHelper.*
import static extension tools.vitruv.applications.util.temporary.java.JavaContainerAndClassifierUtil.*
import org.emftext.language.java.containers.ContainersPackage
import org.emftext.language.java.JavaUniquePathConstructor

// TODO Some duplication with JavaSubPackagesOperator
@ReferenceMappingOperator(
Expand Down Expand Up @@ -50,6 +50,10 @@ class JavaPackageCompilationUnitsOperator extends AbstractReferenceMappingOperat
logger.trace(''' Found compilation units in package '«package.packageString»': «package.compilationUnits»''')
return package.compilationUnits
}

def Iterable<CompilationUnit> compilationUnits(Package package1) {
package1.containedObjects.filter(CompilationUnit).toList
}

override getContainer(EObject object) {
val CompilationUnit compilationUnit = validateObject(object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import tools.vitruv.dsls.reactions.runtime.state.ReactionExecutionState

import static com.google.common.base.Preconditions.*

import static extension tools.vitruv.applications.util.temporary.java.JavaPersistenceHelper.*
import static extension tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaPersistenceHelper.*
import org.emftext.language.java.containers.ContainersPackage

@AttributeMappingOperator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.ResourceSet
import org.emftext.language.java.JavaUniquePathConstructor
import org.emftext.language.java.containers.Package
import tools.vitruv.applications.util.temporary.java.JavaPersistenceHelper
import tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaPersistenceHelper
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.reference.AbstractReferenceMappingOperator
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.reference.ReferenceMappingOperator
import tools.vitruv.dsls.reactions.runtime.state.ReactionExecutionState
Expand All @@ -20,7 +20,7 @@ import static tools.vitruv.dsls.commonalities.runtime.helper.XtendAssertHelper.*
import static extension java.nio.file.Files.*
import static extension tools.vitruv.dsls.commonalities.runtime.helper.IntermediateModelHelper.*

import static extension tools.vitruv.applications.util.temporary.java.JavaContainerAndClassifierUtil.*
import static extension tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaContainerAndClassifierUtil.*
import org.emftext.language.java.containers.ContainersPackage

@ReferenceMappingOperator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.emftext.language.java.types.TypesFactory
import org.emftext.language.java.types.Void
import tools.vitruv.applications.cbs.commonalities.domaincommon.CommonPrimitiveType
import tools.vitruv.applications.cbs.commonalities.domaincommon.operators.AbstractTypeReferenceOperator
import tools.vitruv.applications.util.temporary.java.JavaModificationUtil
import tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaModificationUtil
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.attribute.AttributeMappingOperator
import tools.vitruv.dsls.commonalities.runtime.operators.mapping.attribute.AttributeType
import tools.vitruv.dsls.reactions.runtime.state.ReactionExecutionState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import static com.google.common.base.Preconditions.*
import static tools.vitruv.dsls.commonalities.runtime.helper.XtendAssertHelper.*

import static extension tools.vitruv.applications.cbs.commonalities.java.JavaVisibilityHelper.*
import static extension tools.vitruv.applications.util.temporary.java.JavaModifierUtil.*
import static extension tools.vitruv.applications.cbs.testutils.oldmetamodelutils.JavaModifierUtil.*

@AttributeMappingOperator(
name='javaVisibility',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ Require-Bundle: tools.vitruv.testutils.vsum,
org.hamcrest.core,
org.opentest4j,
tools.vitruv.framework.applications;visibility:=reexport,
tools.vitruv.applications.util.temporary
tools.vitruv.applications.util.temporary,
edu.kit.ipd.sdq.activextendannotations,
org.emftext.language.java.resource,
org.emftext.language.java,
org.apache.log4j,
edu.kit.ipd.sdq.commons.util.java,
edu.kit.ipd.sdq.commons.util.emf
Export-Package: tools.vitruv.applications.cbs.testutils,
tools.vitruv.applications.cbs.testutils.equivalencetest,
tools.vitruv.applications.cbs.testutils.junit
tools.vitruv.applications.cbs.testutils.junit,
tools.vitruv.applications.cbs.testutils.oldmetamodelutils
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package tools.vitruv.applications.cbs.testutils.oldmetamodelutils

import org.emftext.language.java.JavaClasspath
import org.emftext.language.java.JavaClasspath.Initializer
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.common.util.URI
import static com.google.common.base.Preconditions.checkState
import java.nio.file.Path

/**
* This helper class allows to load the Java standard library in JaMoPP also with
* Java versions 9 and above.
* In Java 9 the boot classpath was removed and the standard library is packaged
* differently, which is corrected by this patch.
*/
class JamoppLibraryHelper {
static String STANDARD_LIBRARY_FOLDER_IN_HOME = "/jmods/"
static String BASE_LIBRARY_NAME = "java.base"

/**
* Registers the Java standard library. In case of Java 8 and below, this is the deployed standard library.
* In case of Java 9 and above, this is the "java.base" module. Further modules can be registered with
* the {@link #registerStdLibraryModule} method.
*/
static def void registerStdLib() {
val String javaVersion = System.getProperty("java.version")

// Until Java 1.8 we can use the mechanism of JaMoPP
if (javaVersion.startsWith("1.")) {
JavaClasspath.get().registerStdLib();
// From Java 9 on, we have to search for the Java base module instead of the rt.jar file.
// To do so, we disable automatic initialization of the standard library using the classpath
// (where library cannot be found in Java 9 and above) and manually load the base Java module
} else {
JavaClasspath.initializers.add(new Initializer() {
override initialize(Resource resource) {}

override requiresLocalClasspath() { false }

override requiresStdLib() { false }
})
registerStdLibraryModule(BASE_LIBRARY_NAME)
}
}

/**
* Registers the Java standard library module with the given name.
* This may only be called when using Java in version 9 or above.
* Otherwise, it will throw an {@link IllegalStateException}.
* @param name - the name of the module to register
*/
static def void registerStdLibraryModule(String name) {
val String javaVersion = System.getProperty("java.version");
checkState(!javaVersion.startsWith("1."), "Modules can only be registered in Java version 9 and above")

val modulePath = System.getProperty("java.home") + STANDARD_LIBRARY_FOLDER_IN_HOME + name + ".jmod"
val moduleUri = URI.createFileURI(modulePath)
// From java 9, the module files do not directly contain the classes in the package structure
// but are placed in the "classes" folder, so that prefix has to be removed.
JavaClasspath.get().registerClassifierJar(moduleUri, "classes/");
}

/**
* Registers the library placed at the given path to. The library must
* be an archive (like a ".jar" file) directly containing the package structure
* to be imported.
* @param pathToLibrary - the path to the library to register
*/
static def void registerLocalLibrary(Path pathToLibrary) {
JavaClasspath.get().registerClassifierJar(URI.createFileURI(pathToLibrary.toString), "");
}

}
Loading
Loading