From f0294e250787fccd33e0c3776db8cb30ef7f3ac6 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Mon, 31 Mar 2025 13:19:39 +0200 Subject: [PATCH 1/9] Add IntelliJ Config --- .idea/.gitignore | 8 ++++++++ .idea/compiler.xml | 13 +++++++++++++ .idea/encodings.xml | 11 +++++++++++ .idea/jarRepositories.xml | 20 ++++++++++++++++++++ .idea/misc.xml | 14 ++++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/use_plugins.iml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ 8 files changed, 88 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/use_plugins.iml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 00000000..d8e0b6bd --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..feb09aed --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 00000000..712ab9d9 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..0fad30eb --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..b0ba93f1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/use_plugins.iml b/.idea/use_plugins.iml new file mode 100644 index 00000000..4d2f9894 --- /dev/null +++ b/.idea/use_plugins.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 2e4d8a6715a9e78921dc4576887a1cb1cbe88fb7 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Fri, 4 Apr 2025 23:30:45 +0200 Subject: [PATCH 2/9] Add .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2a1d80e7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +**/target +**/.DS_Store From 8cc530cfafd4e7bb1a6e3a8420b07e2664c9c727 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Fri, 4 Apr 2025 23:31:25 +0200 Subject: [PATCH 3/9] Add Project Maven Configuration --- pom.xml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 pom.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..8fdce349 --- /dev/null +++ b/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + + org.tzi.use + plugins + 1.0-SNAPSHOT + pom + + + Monitor/trunk + + + + UTF-8 + + + + + org.tzi.use + use-core + 7.1.1 + + + org.tzi.use + use-gui + 7.1.1 + + + + From 02a0c28524fcaed3bd41a1daac6eaea8fe7bf196 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Fri, 4 Apr 2025 23:31:43 +0200 Subject: [PATCH 4/9] Add Monitor Plugin Maven Configuration --- Monitor/trunk/pom.xml | 83 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Monitor/trunk/pom.xml diff --git a/Monitor/trunk/pom.xml b/Monitor/trunk/pom.xml new file mode 100644 index 00000000..27dd1f71 --- /dev/null +++ b/Monitor/trunk/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + + + org.tzi.use + plugins + 1.0-SNAPSHOT + ../../pom.xml + + + monitor + 1.0-SNAPSHOT + jar + + + 21 + 21 + + + + + it.cnr.imaa.essi + lablib-checkboxtree + 3.2 + system + ${project.basedir}/lib/lablib-checkboxtree-3.2.jar + + + com.google.guava + guava + 12.0 + system + ${project.basedir}/lib/guava-12.0.jar + + + + + ${basedir}/src + + + ${project.basedir}/resources + resources + + **/* + + + + ${project.basedir} + + useplugin.xml + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + true + + --add-exports=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.2 + + MonitorPlugin + + ${project.basedir}/META-INF/MANIFEST.MF + + + + + + + From ea0b5158e0ad6b6d7634ed9bac487a66d4681f16 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Fri, 4 Apr 2025 23:32:00 +0200 Subject: [PATCH 5/9] Add Project README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..9a9c97d5 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Use Plugins + +This repository contains plugins for [USE - UML-based Specification Environment](https://github.com/useocl/use). + +## Requirements + +This project relies on the compiled `use-core` and `use-gui` modules of the `use` project. Build them and save them +to your local Maven repository with the following command: +``` +mvn clean install +``` + +## Maven Build + +The following command will build all the plugins in this project that have respective pom.xml files: +``` +mvn clean package +``` + +## Maven Support + +Currently, only the `Monitor Plugin` can be built with Maven. If you require any other plugins, you will need to +use the .jardesc files on the Eclipse IDE or convert them yourself to Maven pom.xml files. From 127364d38a2b8e8eff9163ae15e2a20b2b732b82 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Fri, 4 Apr 2025 23:32:12 +0200 Subject: [PATCH 6/9] Add Monitor Plugin README.md --- Monitor/trunk/README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Monitor/trunk/README.md diff --git a/Monitor/trunk/README.md b/Monitor/trunk/README.md new file mode 100644 index 00000000..e894378c --- /dev/null +++ b/Monitor/trunk/README.md @@ -0,0 +1,25 @@ +# USE Monitor + +This plugin adds runtime monitoring capabilities to USE. + +## Instructions + +### 1. Build the JAR with Maven + +The following command will build the `MonitorPlugin.jar` in the target directory: +``` +mvn clean package +``` + +### 2. Copy the MonitorPlugin.jar and its Dependencies Over to USE + +- Copy `MonitorPlugin.jar` over to USE under `${USE_DIR}/lib/plugins` +- Copy `lablib-checkboxtree-3.2.jar` over to USE under `${USE_DIR}/lib` +- Copy `guava-12.0.jar` over to USE under `${USE_DIR}/lib` + +### 3. Modify the USE Start Script + +Add the following argument to the java command in the USE start script for your OS under `${USE_DIR}/bin`. +``` +--add-exports jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED +``` From 12efcc0af7b0a6750637bc2cc3775698d063d313 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Fri, 4 Apr 2025 23:34:06 +0200 Subject: [PATCH 7/9] Remove Unused Dependency from Classpath --- Monitor/trunk/META-INF/MANIFEST.MF | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Monitor/trunk/META-INF/MANIFEST.MF b/Monitor/trunk/META-INF/MANIFEST.MF index 7614d8b3..59b29933 100644 --- a/Monitor/trunk/META-INF/MANIFEST.MF +++ b/Monitor/trunk/META-INF/MANIFEST.MF @@ -3,4 +3,4 @@ Plugin-Name: Monitor Plugin-Version: 0.1 Plugin-Publisher: Lars Hamann Main-Class: org.tzi.use.plugins.monitor.MonitorPlugin -Class-Path: ../tools.jar ../lablib-checkboxtree-3.2.jar ../guava-12.0.jar +Class-Path: ../lablib-checkboxtree-3.2.jar ../guava-12.0.jar From cce5f4bdf489e82e06d7c08248d04d40b6970396 Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Sat, 5 Apr 2025 00:18:22 +0200 Subject: [PATCH 8/9] Fix Compile Errors and JavaDocs --- .../org/tzi/use/plugins/monitor/Monitor.java | 57 +++++++++++-------- .../monitor/gui/MonitorControlView.java | 14 +---- .../monitor/vm/adapter/jvm/JVMAdapter.java | 2 +- 3 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Monitor/trunk/src/org/tzi/use/plugins/monitor/Monitor.java b/Monitor/trunk/src/org/tzi/use/plugins/monitor/Monitor.java index afd995f7..2513277e 100644 --- a/Monitor/trunk/src/org/tzi/use/plugins/monitor/Monitor.java +++ b/Monitor/trunk/src/org/tzi/use/plugins/monitor/Monitor.java @@ -207,13 +207,13 @@ public class Monitor implements ChangeListener { /** * Internal mapping for the adapters from a VM specific key - * to the intermediate representation as a {@link VMOperation}. + * to the intermediate representation as a {@link VMMethod}. */ private BiMap adapterMethodMapping; /** * Internal mapping for the adapters from a VM specific key - * to the intermediate representation as a {@link VMOperation}. + * to the intermediate representation as a {@link VMMethod}. */ private BiMap adapterFieldMapping; @@ -310,7 +310,7 @@ private void waitForUserInput() { * In detail the following steps are executed: *
    *
  1. Reset of the USE session.
  2. - *
  3. Connect to the VM with the settings provided to {@link #configure(Session, String, String)}.
  4. + *
  5. Connect to the VM with the settings provided to {@link #configure(Session, VMAdapter)}.
  6. *
  7. Register for important events in the VM
  8. *
  9. Resume the VM
  10. *
  11. If suspend is true call {@link #pause(boolean)} without reseting.
  12. @@ -448,8 +448,7 @@ private void calculateCurrentCallStack() { /** * Generates and executes a USE operation call from the provided values. * @param self The MObject representing self for the operation call. - * @param useOperation - * @param frame + * @param call * @param validatePreConditions */ private boolean createOperationCall(MObject self, VMMethodCall call, boolean validatePreConditions) { @@ -476,7 +475,7 @@ private boolean createOperationCall(MObject self, VMMethodCall call, boolean val PPCHandler handler = (validatePreConditions ? ppcHandler : DoNothingPPCHandler.getInstance()); MEnterOperationStatement operationCall = new MEnterOperationStatement( - new ExpObjRef(self), useOperation, arguments, handler ); + new ExpObjRef(self), useOperation, arguments.values().toArray(new Expression[0]), handler); try { StatementEvaluationResult result = getSystem().execute(operationCall); @@ -640,7 +639,7 @@ private void registerOperationBreakPoints(VMType vmType) { fireNewLogMessage(Level.FINE, "Registering link modification interest for class " + cls.name()); // Association ends with multiplicity 1 can be handled also - for (Map.Entry end : cls.navigableEnds().entrySet()) { + for (Entry end : cls.navigableEnds().entrySet()) { if (!end.getValue().isCollection() && end.getValue() instanceof MAssociationEnd) { MAssociationEnd assEnd = (MAssociationEnd)end.getValue(); @@ -728,7 +727,7 @@ private void setupClassMappings() { } VMType vmType = getVMType(useClass); - if (!vmType.isClassType()) { + if (vmType != null && !vmType.isClassType()) { fireNewLogMessage(Level.FINE, String.format("Found VM type for class %s, but the returned type is not a class", useClass.name())); } @@ -838,8 +837,8 @@ protected MObject createInstance(MClass cls, VMObject vmObj) if (useSoil) { MNewObjectStatement stmt = new MNewObjectStatement(cls, (String)null); - getSystem().execute(stmt); - useObject = stmt.getCreatedObject(); + StatementEvaluationResult result = getSystem().execute(stmt); + useObject = getSystem().createObject(result, stmt.getObjectClass(), stmt.getObjectName().name()); } else { String name = getSystem().state().uniqueObjectNameForClass(cls); useObject = getSystem().state().createObject(cls, name); @@ -865,7 +864,7 @@ private void checkForDeletedInstances() { if (!refObject.isAlive()) { MObject useObj = refObject.getUSEObject(); - ObjectValue valObject = new ObjectValue(useObj.type(), useObj); + ObjectValue valObject = new ObjectValue(useObj.cls(), useObj); MObjectDestructionStatement delStmt = new MObjectDestructionStatement(valObject); try { this.getSystem().execute(delStmt); @@ -1066,7 +1065,7 @@ private void readLink(VMObject objRef, MObject source, MAssociationEnd end) { } catch (Exception e) { fireNewLogMessage(Level.SEVERE, "ERROR: " + e.getMessage()); } - } else if (fieldValue.isSet() && ((SetValue)fieldValue).elemType().isTupleType(true)) { + } else if (fieldValue.isSet() && ((SetValue)fieldValue).elemType().isTypeOfTupleType()) { // Qualified association SetValue setValue = (SetValue)fieldValue; @@ -1090,8 +1089,7 @@ private void readLink(VMObject objRef, MObject source, MAssociationEnd end) { * Reads qualified links from a Set(Tuple(key,value)) * @param source * @param end - * @param seqValue - * @param qualifierValues + * @param setValue */ private void readQualifiedLinks(MObject source, MAssociationEnd end, SetValue setValue) { List qualifier = new LinkedList(); @@ -1114,9 +1112,10 @@ private void readQualifiedLinks(MObject source, MAssociationEnd end, SetValue se } /** - * @param i + * @param source + * @param end + * @param seqValue * @param qualifierValues - * @return */ private void readQualifiedLinks(MObject source, MAssociationEnd end, SequenceValue seqValue, List qualifierValues) { for (int i = 0; i < seqValue.size(); ++i) { @@ -1299,7 +1298,17 @@ public void handlePostConditions(MSystem system, if (oneFailed) { throw new PostConditionCheckFailedException(operationCall); } - + + } + + @Override + public void handleTransitionsPre(MSystem system, MOperationCall operationCall) throws PreConditionCheckFailedException { + + } + + @Override + public void handleTransitionsPost(MSystem system, MOperationCall operationCall) throws PostConditionCheckFailedException { + } } @@ -1466,10 +1475,9 @@ public void storeVMMethod(Object key, VMMethod type) { } /** - * Needs to be called if a method is called - * which the monitor registered for. - * The monitor will call all other adapter methods. - * @param vmMethodId The id of the method returned by {@link VMMethod#getId()} + * Needs to be called if a method is called, which the monitor registered for. + * The monitor will call all other adapter methods. + * @param vmMethodCall The method called */ public void onMethodCall(VMMethodCall vmMethodCall) { /* @@ -1566,7 +1574,7 @@ public void onMethodExit(Object adapterExitInformation, Object adapterMethodId) result = new ExpressionWithValue(resultValue); } - MExitOperationStatement stmt = new MExitOperationStatement(result, ppcHandler, currentUseOperationCall); + MExitOperationStatement stmt = new MExitOperationStatement(result, ppcHandler); try { StatementEvaluationResult statResult = getSystem().execute(stmt); @@ -1594,6 +1602,7 @@ public void onMethodExit(Object adapterExitInformation, Object adapterMethodId) /** + * @param adapterEventInformation * @param type */ public void onNewVMTypeLoaded(Object adapterEventInformation, JVMType type) { @@ -1626,8 +1635,8 @@ public void onNewVMObject(VMObject newInstance) { } /** - * @param obj - * @param field + * @param objId + * @param fieldId * @param useValue */ public void onUpdateAttribute(Object objId, Object fieldId, Value useValue) { diff --git a/Monitor/trunk/src/org/tzi/use/plugins/monitor/gui/MonitorControlView.java b/Monitor/trunk/src/org/tzi/use/plugins/monitor/gui/MonitorControlView.java index cb67e7f1..9a9055d6 100644 --- a/Monitor/trunk/src/org/tzi/use/plugins/monitor/gui/MonitorControlView.java +++ b/Monitor/trunk/src/org/tzi/use/plugins/monitor/gui/MonitorControlView.java @@ -72,18 +72,15 @@ import org.tzi.use.plugins.monitor.vm.adapter.InvalidAdapterConfiguration; import org.tzi.use.plugins.monitor.vm.adapter.VMAdapter; import org.tzi.use.plugins.monitor.vm.adapter.VMAdapterSetting; -import org.tzi.use.plugins.monitor.vm.adapter.jvm.JVMAdapter; import org.tzi.use.uml.mm.MAssociation; import org.tzi.use.uml.mm.MAttribute; import org.tzi.use.uml.mm.MClass; import org.tzi.use.uml.mm.MModel; import org.tzi.use.uml.mm.MOperation; -import org.tzi.use.uml.sys.StateChangeEvent; -import org.tzi.use.uml.sys.StateChangeListener; import org.tzi.use.util.StringUtil; @SuppressWarnings("serial") -public class MonitorControlView extends JDialog implements StateChangeListener, ChangeListener, ProgressListener, LogListener { +public class MonitorControlView extends JDialog implements ChangeListener, ProgressListener, LogListener { private Session session; @@ -164,7 +161,7 @@ protected void doMonitorInBackground() { if (check_suspend.isSelected() && check_determineStates.isSelected()) session.system() .state() - .determineStates( + .checkStateInvariants( new PrintWriter(new LogAreaWriter( "Determining states..."), true)); @@ -195,7 +192,7 @@ protected void doMonitorInBackground() { && check_determineStates.isSelected()) session.system() .state() - .determineStates( + .checkStateInvariants( new PrintWriter( new LogAreaWriter( "Determining states..."), @@ -511,11 +508,6 @@ private void configureComponents() { this.button_Pause.setSelected(isPaused); this.button_Stop.setEnabled(isMonitoring); } - - @Override - public void stateChanged(StateChangeEvent e) { - - } /* (non-Javadoc) * @see java.awt.Window#dispose() diff --git a/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java b/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java index 0e3689a1..0629ffc4 100644 --- a/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java +++ b/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java @@ -449,7 +449,7 @@ public Value getUSEValue(com.sun.jdi.Value javaValue) { if (controller.existsVMObject(javaValue)) { VMObject obj = controller.getVMObject(javaValue); - v = new ObjectValue(obj.getUSEObject().type(), obj.getUSEObject()); + v = new ObjectValue(obj.getUSEObject().cls(), obj.getUSEObject()); } else if (javaValue instanceof ArrayReference) { ArrayReference javaArray = (ArrayReference)javaValue; List javaValues = javaArray.getValues(); From bae3b17cb88002ffe547aee3d5f16278b3ca282a Mon Sep 17 00:00:00 2001 From: Sergio Jimenez Date: Sat, 5 Apr 2025 00:18:46 +0200 Subject: [PATCH 9/9] Fix Monitor Start Argument Handling --- .../plugins/monitor/cmd/StartMonitorCmd.java | 24 ++++++++----------- .../monitor/vm/adapter/jvm/JVMAdapter.java | 2 ++ 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Monitor/trunk/src/org/tzi/use/plugins/monitor/cmd/StartMonitorCmd.java b/Monitor/trunk/src/org/tzi/use/plugins/monitor/cmd/StartMonitorCmd.java index 2729f079..14dce751 100644 --- a/Monitor/trunk/src/org/tzi/use/plugins/monitor/cmd/StartMonitorCmd.java +++ b/Monitor/trunk/src/org/tzi/use/plugins/monitor/cmd/StartMonitorCmd.java @@ -4,6 +4,7 @@ import org.tzi.use.plugins.monitor.MonitorPlugin; import org.tzi.use.plugins.monitor.vm.adapter.InvalidAdapterConfiguration; import org.tzi.use.plugins.monitor.vm.adapter.VMAdapter; +import org.tzi.use.plugins.monitor.vm.adapter.jvm.JVMAdapter; import org.tzi.use.util.Log; import org.tzi.use.util.StringUtil; @@ -12,26 +13,23 @@ public class StartMonitorCmd extends AbstractMonitorCmd { @Override public void doPerformCommand(IPluginShellCmd pluginCommand) { if (MonitorPlugin.getInstance().getMonitor().isRunning()) { - Log.error("Already monitioring an application. Please stop before starting a new monitor."); + Log.error("Already monitoring an application. Please stop before starting a new monitor."); return; } - String[] args = pluginCommand.getCmdArguments().split(" "); - + String[] args = pluginCommand.getCmdArgumentList(); + String adapterName; if (args.length == 0) { + adapterName = JVMAdapter.JVM_ADAPTER_NAME; Log.println("Using default value for JVM remote debugger: localhost:6000"); - } - - String adpaterName = args[0]; - VMAdapter adapter = MonitorPlugin.getInstance().getAdapterRegistry().getAdapterByName(adpaterName); + } else { + adapterName = args[0]; + } + VMAdapter adapter = MonitorPlugin.getInstance().getAdapterRegistry().getAdapterByName(adapterName); if (adapter == null) { - Log.print("Invalid adapter name " + StringUtil.inQuotes(adpaterName) + " specified."); + Log.println("Invalid adapter name " + StringUtil.inQuotes(adapterName) + " specified."); return; - } - - for (int i = 1; i < args.length;++i) { - } try { @@ -41,6 +39,4 @@ public void doPerformCommand(IPluginShellCmd pluginCommand) { } } - - } diff --git a/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java b/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java index 0629ffc4..419d3cc6 100644 --- a/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java +++ b/Monitor/trunk/src/org/tzi/use/plugins/monitor/vm/adapter/jvm/JVMAdapter.java @@ -81,6 +81,8 @@ */ public class JVMAdapter extends AbstractVMAdapter { + public static final String JVM_ADAPTER_NAME = "JVMAdapter"; + private static final int SETTING_HOST = 0; private static final int SETTING_PORT = 1;