Project

General

Profile

Bug #3253

Implement hashCode methods for DSML elements implementing "equals"

Added by Alexander Diewald over 2 years ago. Updated 2 days ago.

Status:
Feedback
Priority:
Normal
Assignee:
Category:
-
Target version:
Start date:
01/29/2018
Due date:
% Done:

0%

Estimated time:
1.00 h

Description

Current status

Some EClasses in the DSML, e.g., the ModelElementLiteral, override the equals method but not the hashCode method. This is strongly discouraged by the Java API Designers since it can easily cause inconsistent behavior, e.g., in sort algorithms.

Resolution

Implement hashCode methods where there are equals methods and align them with the logic of these methods.

History

#1 Updated by Alexander Diewald over 2 years ago

  • Status changed from New to In Progress

#2 Updated by Alexander Diewald over 2 years ago

  • Status changed from In Progress to Feedback

Are the equals methods used at all? See the following result from a grep:

diewald@fortiss-n-089 /cygdrive/c/Users/diewald/eclipse/autofocus3-oxygen/ws/org .fortiss.af3.exploration.smt/src
$ grep -r "equals("
org/fortiss/af3/exploration/smt/modeltransformation/DSLtoSMT.java: if(specificationType.equals(StartTimeDummy.class)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/ConstraintToNONQuantifiedSMT.java: if(specificationType.equals(StartTimeDummy.class)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/ConstraintToQuantifiedSMT.java: if(element.toString().equals(uniqueModelName)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/ConstraintToQuantifiedSMT.java: if(!setReference.equals(sum.getSet())) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/ConstraintToQuantifiedSMT.java: if(leftModel.getSetReference().equals(sum.getSet())) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/ConstraintToQuantifiedSMT.java: if(rightModel.getSetReference().equals(sum.getSet())) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/LanguageTransformation.java: if(specificationType.equals(StartTimeDummy.class) ||
org/fortiss/af3/exploration/smt/modeltransformation/rework/LanguageTransformation.java: specificationType.equals(DurationDummy.class)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/LanguageTransformation.java: .filter(be -> be.toString().equals(createEqual.toString()))
org/fortiss/af3/exploration/smt/modeltransformation/rework/SolverRun2.java: if(check.equals(Status.UNSATISFIABLE) && models.isEmpty()) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/SolverRun2.java: if(check.equals(Status.UNKNOWN)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/SolverRun2.java: if(check.equals(Status.UNSATISFIABLE)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/SolverRun2.java: } else if(check.equals(Status.SATISFIABLE)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/SolverRun2.java: } else if(check.equals(Status.UNKNOWN)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/SolverRun2.java: if(!ExplorationUtils.getReturnTypeOf(entry.getValue()).equals(Integer.class)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/TransformationService.java: if(expr.toString().equals(name) || expr.toString().equals("|" + name + "|")) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/TransformationService.java: if(element.toString().equals(uniqueModelName)) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/TransformationService.java: // if(element.toString().equals(expr.toString())) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/TransformationService.java: if(expr.toString().equals(element.toString()) ||
org/fortiss/af3/exploration/smt/modeltransformation/rework/TransformationService.java: expr.toString().equals("|" + element.toString() + "|")) {
org/fortiss/af3/exploration/smt/modeltransformation/rework/TransformationService.java: return element.toString().equals(uName) ||
org/fortiss/af3/exploration/smt/modeltransformation/rework/TransformationService.java: element.toString().equals("|" + uName + "|");
org/fortiss/af3/exploration/smt/modeltransformation/ScheduleRun.java: childrenWithType.stream().filter(p -> p.equals(modelElement))
org/fortiss/af3/exploration/smt/modeltransformation/SolverRun.java: if(check.equals(Status.UNSATISFIABLE) && models.isEmpty()) {
org/fortiss/af3/exploration/smt/modeltransformation/SolverRun.java: if(comp.getValue().equals(source)) {
org/fortiss/af3/exploration/smt/modeltransformation/SolverRun.java: if(comp.getValue().equals(target)) {
org/fortiss/af3/exploration/smt/modeltransformation/SolverRun.java: if(check.equals(Status.UNSATISFIABLE)) {
org/fortiss/af3/exploration/smt/modeltransformation/SolverRun.java: } else if(check.equals(Status.SATISFIABLE)) {
org/fortiss/af3/exploration/smt/modeltransformation/SolverRun.java: if(specificationType.equals(StartTimeDummy.class) ||
org/fortiss/af3/exploration/smt/modeltransformation/SolverRun.java: specificationType.equals(DurationDummy.class)) {
org/fortiss/af3/exploration/smt/util/AllocationToSchedule.java: if(deplTargetA.equals(deplTargetB)) {
org/fortiss/af3/exploration/smt/util/RouteUtils.java: if(e1.equals(e2)) {
org/fortiss/af3/exploration/smt/util/RouteUtils.java: if(newDestination.equals(ecu2)) {
org/fortiss/af3/exploration/smt/util/RouteUtils.java: if(v.equals(source)) {
org/fortiss/af3/exploration/smt/util/RouteUtils.java: if(segment.getElement().equals(tu)) {

diewald@fortiss-n-089 /cygdrive/c/Users/diewald/eclipse/autofocus3-oxygen/ws/org.fortiss.af3.exploration.smt/src
$ cd ../../org.fortiss.af3.exploration.ui/src

diewald@fortiss-n-089 /cygdrive/c/Users/diewald/eclipse/autofocus3-oxygen/ws/org.fortiss.af3.exploration.ui/src
$ grep -r "equals("
org/fortiss/af3/exploration/ui/perspective/constraint/AllocationPatternCompositeBackend.java: if(event.getSource().equals(leftTreeViewer)) {
org/fortiss/af3/exploration/ui/perspective/constraint/AllocationPatternCompositeBackend.java: } else if(event.getSource().equals(rightTreeViewer)) {
org/fortiss/af3/exploration/ui/perspective/dashboard/projectwizard/DashboardWizardSelectProjectSource.java: if(element.equals(project) && !childrenWithType.isEmpty()) {
org/fortiss/af3/exploration/ui/perspective/dashboard/projectwizard/DashboardWizardSelectTA.java: // if(element.equals(platformArchitecure)) {
org/fortiss/af3/exploration/ui/perspective/dashboard/projectwizard/DashboardWizardSelectTA.java: if(platformArchitecure.equals(pa) &&
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorLabelProvider.java: if(currentProcessStep.equals(PLATFORM_SYNTHESIS) ||
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorLabelProvider.java: currentProcessStep.equals(DEPLOYMENT_SYNTHESIS) ||
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorLabelProvider.java: currentProcessStep.equals(SCHEDULE_SYNTHESIS)) {
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorLabelProvider.java: (currentProcessStep.equals(CONSTRAINTS) || currentProcessStep.equals(OBJECTIVES))) {
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorTreeContentProvider.java: if(currentProcessStep.equals(IProcessManager.EProcessStep.PLATFORM_SYNTHESIS) ||
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorTreeContentProvider.java: currentProcessStep.equals(IProcessManager.EProcessStep.DEPLOYMENT_SYNTHESIS) ||
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorTreeContentProvider.java: currentProcessStep.equals(IProcessManager.EProcessStep.SCHEDULE_SYNTHESIS)) {
org/fortiss/af3/exploration/ui/perspective/navigator/DSENavigatorTreeContentProvider.java: return !parentElement.isEmpty() && !parentElement.get(0).equals(inputElement)
org/fortiss/af3/exploration/ui/perspective/objective/HardwareOptimizationPatternCompositeBackend.java: if(event.getSource().equals(listViewerSetProperty)) {
org/fortiss/af3/exploration/ui/perspective/service/DSEPerspectiveManager.java: public boolean equals(Object object) {
org/fortiss/af3/exploration/ui/perspective/visualization/visualizations/fourD/Editor4DBackend.java: if(min.equals(max)) {
org/fortiss/af3/exploration/ui/perspective/visualization/visualizations/table/TableVisualization.java: dataset.getPoints().stream().filter(s -> s.getAxis().equals(axis)).findFirst()
org/fortiss/af3/exploration/ui/perspective/visualization/visualizations/VisualizationViewFactory.java: if(visualizationView.equals(IVisualizationView.ViewConstants.SPIDER)) {
org/fortiss/af3/exploration/ui/perspective/visualization/visualizations/VisualizationViewFactory.java: if(visualizationView.equals(IVisualizationView.ViewConstants.FOURD)) {
org/fortiss/af3/exploration/ui/perspective/visualization/visualizations/VisualizationViewFactory.java: if(visualizationView.equals(IVisualizationView.ViewConstants.TABLE)) {
org/fortiss/af3/exploration/ui/util/DSETreeContentProvider.java: return !parentElement.isEmpty() && !parentElement.get(0).equals(inputElement)
org/fortiss/af3/exploration/ui/util/ExplorationUiUtil.java: if(!topComponents.get(i).equals(topComponents.get(i + 1))) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: if(point.getAxis().equals(axis) && point.getStart() instanceof Double) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: } else if(point.getAxis().equals(axis) && point.getStart() instanceof Integer) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: if(point.getAxis().equals(axis) && point.getStart() instanceof Double) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: } else if(point.getAxis().equals(axis) && point.getStart() instanceof Integer) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: if(point.getAxis().equals(axis) && point.getStart() instanceof Double) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: } else if(point.getAxis().equals(axis) && point.getStart() instanceof Integer) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: if(point.getAxis().equals(axis) && point.getStart() instanceof Double) {
org/fortiss/af3/exploration/ui/util/SpiderChartUtils.java: } else if(point.getAxis().equals(axis) && point.getStart() instanceof Integer) {

diewald@fortiss-n-089 /cygdrive/c/Users/diewald/eclipse/autofocus3-oxygen/ws/org.fortiss.af3.exploration.ui/src

This issue should be best discussed during the next DSE JF.

#3 Updated by Alexander Diewald over 2 years ago

  • Assignee changed from Alexander Diewald to Johannes Eder

#4 Updated by Johannes Eder over 2 years ago

Equals is especially useful when e.g. list.contains is called. In that case it is desirable to not compare the object but the expression which is used. It is thus used implicitly.

#5 Updated by Johannes Eder over 2 years ago

  • Target version changed from AF3 2.13 RC1 (Feature Freeze) to AF3 2.14 RC1 (Feature Freeze)

I will move this issue to the next release as it is not urgent and causes a lot of work.

#6 Updated by Johannes Eder over 1 year ago

  • Target version changed from AF3 2.14 RC1 (Feature Freeze) to Backlog

#7 Updated by Johannes Eder over 1 year ago

  • Target version changed from Backlog to AF3 2.16 RC1 (Feature Freeze)

#8 Updated by Johannes Eder over 1 year ago

  • Target version changed from AF3 2.16 RC1 (Feature Freeze) to AF3 2.16 RC2 (Tested, Bug-free)

#9 Updated by Simon Barner about 1 year ago

  • Target version changed from AF3 2.16 RC2 (Tested, Bug-free) to AF3 2.17 (Feature Freeze)

#10 Updated by Johannes Eder 8 months ago

  • Target version changed from AF3 2.17 (Feature Freeze) to AF3 2.17 (Tested, Bug Free)

#11 Updated by Johannes Eder 6 months ago

  • Target version changed from AF3 2.17 (Tested, Bug Free) to AF3 2.18 - Critical bugs fixed

#12 Updated by Johannes Eder 2 days ago

  • Target version changed from AF3 2.18 - Critical bugs fixed to Backlog

Also available in: Atom PDF