amino-os / Amino.Run

Amino Distributed OS - Runtime Manager
Apache License 2.0
29 stars 12 forks source link

Removed unused return from void method in stubs #809

Closed Vishwa4jeet closed 5 years ago

Vishwa4jeet commented 5 years ago

Fixes #713

Removed unused return value for void method from generated stubs.

Screenshots:

  1. Stub method generation:

    // Implementation of getServers()
    public java.util.ArrayList getServers()
            throws java.rmi.RemoteException {
        java.util.ArrayList<Object> $__params = new java.util.ArrayList<Object>();
        String $__method = "public java.util.ArrayList<amino.run.policy.Policy$ServerPolicy> amino.run.policy.DefaultPolicy$DefaultGroupPolicy.getServers() throws java.rmi.RemoteException";
        java.lang.Object $__result = null;
        try {
            $__result = $__makeKernelDMRPC($__method, $__params);
        } catch (java.rmi.RemoteException e) {
            throw e;
        } catch (java.lang.RuntimeException e) {
            throw e;
        } catch (java.lang.Exception e) {
            throw new java.lang.RuntimeException(e);
        }
        return ((java.util.ArrayList) $__result);
    }
    
    // Implementation of $__initialize(String, ArrayList)
    public void $__initialize(java.lang.String $param_String_1, java.util.ArrayList $param_ArrayList_2) {
        java.util.ArrayList<Object> $__params = new java.util.ArrayList<Object>();
        String $__method = "public void amino.run.policy.DefaultUpcallImpl$GroupPolicy.$__initialize(java.lang.String,java.util.ArrayList<java.lang.Object>)";
        $__params.add($param_String_1);
        $__params.add($param_ArrayList_2);
        try {
            $__makeKernelDMRPC($__method, $__params);
        } catch (java.lang.RuntimeException e) {
            throw e;
        } catch (java.lang.Exception e) {
            throw new java.lang.RuntimeException(e);
        }
    }
  2. Proof of clean build post the change:

Selection_026

quinton-hoole commented 5 years ago

Other than trying to close issue #713, why are we doing this at all? What problem does it solve?

VenuReddy2103 commented 5 years ago

Agreed with @quinton-hoole I understand that, we tried to remove $__result variable declaration itself if the method do not have anything to return. In fact, java.lang.Object $__result doesn't have to be explicitly initialized with null. Also these change you made are applicable for AppStub generation too(not just for policyStub). We should fix issues based on priority.