This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 209018
Collapse All | Expand All

(-)a/core.startup/nbproject/project.xml (-1 / +1 lines)
Lines 79-85 Link Here
79
                    <build-prerequisite/>
79
                    <build-prerequisite/>
80
                    <compile-dependency/>
80
                    <compile-dependency/>
81
                    <run-dependency>
81
                    <run-dependency>
82
                        <specification-version>8.1</specification-version>
82
                        <specification-version>8.23</specification-version>
83
                    </run-dependency>
83
                    </run-dependency>
84
                </dependency>
84
                </dependency>
85
                <dependency>
85
                <dependency>
(-)a/core.startup/src/org/netbeans/core/startup/ModuleLifecycleManager.java (-1 / +5 lines)
Lines 67-72 Link Here
67
67
68
    private final AtomicBoolean exiting = new AtomicBoolean(false);
68
    private final AtomicBoolean exiting = new AtomicBoolean(false);
69
    public void exit() {
69
    public void exit() {
70
        exit(0);
71
    }
72
    
73
    public void exit(int status) {
70
        if (exiting.getAndSet(true)) {
74
        if (exiting.getAndSet(true)) {
71
            return;
75
            return;
72
        }
76
        }
Lines 90-96 Link Here
90
                Exceptions.printStackTrace(t);
94
                Exceptions.printStackTrace(t);
91
            }
95
            }
92
            if (System.getProperty("netbeans.close.no.exit") == null) {
96
            if (System.getProperty("netbeans.close.no.exit") == null) {
93
                TopSecurityManager.exit(0);
97
                TopSecurityManager.exit(status);
94
            }
98
            }
95
        }
99
        }
96
    }
100
    }
(-)a/o.n.core/nbproject/project.xml (-1 / +1 lines)
Lines 160-166 Link Here
160
                    <build-prerequisite/>
160
                    <build-prerequisite/>
161
                    <compile-dependency/>
161
                    <compile-dependency/>
162
                    <run-dependency>
162
                    <run-dependency>
163
                        <specification-version>8.17</specification-version>
163
                        <specification-version>8.23</specification-version>
164
                    </run-dependency>
164
                    </run-dependency>
165
                </dependency>
165
                </dependency>
166
                <dependency>
166
                <dependency>
(-)a/o.n.core/src/org/netbeans/core/NbLifecycleManager.java (-6 / +18 lines)
Lines 111-126 Link Here
111
        Mutex.EVENT.readAccess(DO_EXIT);
111
        Mutex.EVENT.readAccess(DO_EXIT);
112
    }
112
    }
113
113
114
    public void exit(int status) {
115
        ExitActions action = new ExitActions(0, status);
116
        Mutex.EVENT.readAccess(action);
117
    }
118
114
    private static class ExitActions implements Runnable {
119
    private static class ExitActions implements Runnable {
115
        private final int type;
120
        private final int type;
121
        private final int status;
116
        ExitActions(int type) {
122
        ExitActions(int type) {
117
            this.type = type;
123
            this.type = type;
124
            this.status = 0;
125
        }
126
127
        ExitActions(int type, int status) {
128
            this.type = type;
129
            this.status = status;
118
        }
130
        }
119
131
120
        public void run() {
132
        public void run() {
121
            switch (type) {
133
            switch (type) {
122
                case 0:
134
                case 0:
123
                    doExit();
135
                    doExit(status);
124
                    break;
136
                    break;
125
                case 1:
137
                case 1:
126
                    CLIHandler.stopServer();
138
                    CLIHandler.stopServer();
Lines 132-143 Link Here
132
                    }
144
                    }
133
                    if (Boolean.getBoolean("netbeans.close.when.invisible")) {
145
                    if (Boolean.getBoolean("netbeans.close.when.invisible")) {
134
                        // hook to permit perf testing of time to *apparently* shut down
146
                        // hook to permit perf testing of time to *apparently* shut down
135
                        TopSecurityManager.exit(0);
147
                        TopSecurityManager.exit(status);
136
                    }
148
                    }
137
                    break;
149
                    break;
138
                case 2:
150
                case 2:
139
                    if (!Boolean.getBoolean("netbeans.close.no.exit")) { // NOI18N
151
                    if (!Boolean.getBoolean("netbeans.close.no.exit")) { // NOI18N
140
                        TopSecurityManager.exit(0);
152
                        TopSecurityManager.exit(status);
141
                    }
153
                    }
142
                    break;
154
                    break;
143
                default:
155
                default:
Lines 156-162 Link Here
156
        return doingExit;
168
        return doingExit;
157
    }
169
    }
158
170
159
    private static void doExit() {
171
    private static void doExit(int status) {
160
        if (doingExit) {
172
        if (doingExit) {
161
            return ;
173
            return ;
162
        }
174
        }
Lines 164-170 Link Here
164
        // save all open files
176
        // save all open files
165
        try {
177
        try {
166
            if ( System.getProperty ("netbeans.close") != null || ExitDialog.showDialog() ) {
178
            if ( System.getProperty ("netbeans.close") != null || ExitDialog.showDialog() ) {
167
                if (org.netbeans.core.startup.Main.getModuleSystem().shutDown(new ExitActions(1))) {
179
                if (org.netbeans.core.startup.Main.getModuleSystem().shutDown(new ExitActions(1, status))) {
168
                    try {
180
                    try {
169
                        try {
181
                        try {
170
                            NbLoaderPool.store();
182
                            NbLoaderPool.store();
Lines 189-195 Link Here
189
                    // exit is dispatched through that proprietary queue and it
201
                    // exit is dispatched through that proprietary queue and it
190
                    // can be refused by security check. So, we need to replan
202
                    // can be refused by security check. So, we need to replan
191
                    // to RequestProcessor to avoid security problems.
203
                    // to RequestProcessor to avoid security problems.
192
                    Task exitTask = new Task(new ExitActions(2));
204
                    Task exitTask = new Task(new ExitActions(2, status));
193
                    RequestProcessor.getDefault().post(exitTask);
205
                    RequestProcessor.getDefault().post(exitTask);
194
                    exitTask.waitFinished();
206
                    exitTask.waitFinished();
195
                }
207
                }
(-)a/openide.util/apichanges.xml (+17 lines)
Lines 51-56 Link Here
51
    <apidef name="actions">Actions API</apidef>
51
    <apidef name="actions">Actions API</apidef>
52
</apidefs>
52
</apidefs>
53
<changes>
53
<changes>
54
    <change id="exit-code">
55
        <api name="util"/>
56
        <summary>Exit with status code</summary>
57
        <version major="8" minor="23"/>
58
        <date year="2012" month="3" day="8"/>
59
        <author login="jtulach"/>
60
        <compatibility addition="yes" binary="compatible" source="compatible"/>
61
        <description>
62
            <p>
63
                <a href="@TOP@/org/openide/LifecycleManager.html">LifecycleManager</a>
64
                has new <code>exit</code> method allowing callers to specify
65
                the exit code.
66
            </p>
67
        </description>
68
        <class package="org.openide" name="LifecycleManager"/>
69
        <issue number="209018"/>
70
    </change>
54
    <change id="Messages.fields">
71
    <change id="Messages.fields">
55
        <api name="util"/>
72
        <api name="util"/>
56
        <summary><code>@NbBundle.Messages</code> available on fields</summary>
73
        <summary><code>@NbBundle.Messages</code> available on fields</summary>
(-)a/openide.util/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.util
2
OpenIDE-Module: org.openide.util
3
OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/util/Bundle.properties
4
OpenIDE-Module-Specification-Version: 8.22
4
OpenIDE-Module-Specification-Version: 8.23
5
5
(-)a/openide.util/src/org/openide/LifecycleManager.java (+15 lines)
Lines 86-91 Link Here
86
     */
86
     */
87
    public abstract void exit();
87
    public abstract void exit();
88
88
89
    /** Exit NetBeans with the given exit code.
90
     * This method will return only if {@link java.lang.System#exit} fails, or if at least one component of the
91
     * system refuses to exit (because it cannot be properly shut down).
92
     * 
93
     * @param status the exit code of the application
94
     * @since 8.23
95
     */
96
    public void exit(int status) {
97
        exit();
98
    }
99
89
    /**
100
    /**
90
     * Request that the application restart immediately after next being shut down.
101
     * Request that the application restart immediately after next being shut down.
91
     * You may want to then call {@link #exit} to go ahead and restart now.
102
     * You may want to then call {@link #exit} to go ahead and restart now.
Lines 105-110 Link Here
105
            System.exit(0);
116
            System.exit(0);
106
        }
117
        }
107
118
119
        public void exit(int status) {
120
            System.exit(status);
121
        }
122
108
        public void saveAll() {
123
        public void saveAll() {
109
        }
124
        }
110
    }
125
    }

Return to bug 209018