001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Anatoly F. Bondarenko
021: * @version $Revision: 1.5 $
022: */
023:
024: /**
025: * Created on 04.03.2005
026: */package org.apache.harmony.jpda.tests.jdwp.MultiSession;
027:
028: import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer;
029: import org.apache.harmony.jpda.tests.share.SyncDebuggee;
030:
031: public class EnableCollectionDebuggee extends SyncDebuggee {
032:
033: static EnableCollectionObject001_01 checkedObject;
034: static boolean checkedObject_Finalized = false;
035: static EnableCollectionObject001_02 patternObject;
036: static boolean patternObject_Finalized = false;
037:
038: public void run() {
039: logWriter
040: .println("--> Debuggee: EnableCollectionDebuggee: START");
041:
042: checkedObject = new EnableCollectionObject001_01();
043: patternObject = new EnableCollectionObject001_02();
044:
045: synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_READY);
046: String messageFromTest = synchronizer.receiveMessage();
047: if (messageFromTest.equals("TO_FINISH")) {
048: logWriter
049: .println("--> Debuggee: EnableCollectionDebuggee: FINISH");
050: return;
051: }
052:
053: logWriter.println("--> Debuggee: BEFORE System.gc():");
054: logWriter.println("--> Debuggee: checkedObject = "
055: + checkedObject);
056: logWriter.println("--> Debuggee: checkedObject_UNLOADed = "
057: + checkedObject_Finalized);
058: logWriter.println("--> Debuggee: patternObject = "
059: + patternObject);
060: logWriter.println("--> Debuggee: patternObject_UNLOADed = "
061: + patternObject_Finalized);
062:
063: checkedObject = null;
064: patternObject = null;
065: long[][] longArray;
066: int i = 0;
067: try {
068: longArray = new long[1000000][];
069: int arraysNumberLimit = 7; // max - longArray.length
070: logWriter
071: .println("--> Debuggee: memory depletion - creating 'long[1000000]' arrays ("
072: + arraysNumberLimit + ")...");
073: for (; i < arraysNumberLimit; i++) {
074: longArray[i] = new long[1000000];
075: }
076: } catch (OutOfMemoryError outOfMem) {
077: logWriter.println("--> Debuggee: OutOfMemoryError!!!");
078: }
079: longArray = null;
080: System.gc();
081: logWriter.println("--> Debuggee: AFTER System.gc():");
082: logWriter.println("--> Debuggee: checkedObject = "
083: + checkedObject);
084: logWriter.println("--> Debuggee: checkedObject_UNLOADed = "
085: + checkedObject_Finalized);
086: logWriter.println("--> Debuggee: patternObject = "
087: + patternObject);
088: logWriter.println("--> Debuggee: patternObject_UNLOADed = "
089: + patternObject_Finalized);
090:
091: String messageForTest = null;
092: if (checkedObject_Finalized) {
093: if (patternObject_Finalized) {
094: messageForTest = "Checked Object is UNLOADed; Pattern Object is UNLOADed;";
095: } else {
096: messageForTest = "Checked Object is UNLOADed; Pattern Object is NOT UNLOADed;";
097: }
098: } else {
099: if (patternObject_Finalized) {
100: messageForTest = "Checked Object is NOT UNLOADed; Pattern Object is UNLOADed;";
101: } else {
102: messageForTest = "Checked Object is NOT UNLOADed; Pattern Object is NOT UNLOADed;";
103: }
104: }
105: logWriter.println("--> Debuggee: Send to test message: \""
106: + messageForTest + "\"");
107: synchronizer.sendMessage(messageForTest);
108: synchronizer
109: .receiveMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE);
110:
111: logWriter
112: .println("--> Debuggee: EnableCollectionDebuggee: FINISH");
113:
114: }
115:
116: public static void main(String[] args) {
117: runDebuggee(EnableCollectionDebuggee.class);
118: }
119:
120: }
121:
122: class EnableCollectionObject001_01 {
123: protected void finalize() throws Throwable {
124: EnableCollectionDebuggee.checkedObject_Finalized = true;
125: super .finalize();
126: }
127: }
128:
129: class EnableCollectionObject001_02 {
130: protected void finalize() throws Throwable {
131: EnableCollectionDebuggee.patternObject_Finalized = true;
132: super.finalize();
133: }
134: }
|