Check-in [468ce76e8f]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixes for Runtime and Terminal shelves.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-midlevel
Files: files | file ages | folders
SHA1: 468ce76e8f722d6b276f3089bf4e42c26f8ec5bd
User & Date: stephanie.gawroriski 2020-06-30 02:12:08
Context
2020-06-30
02:39
More fixings for the MLE error checking. check-in: f03755ed49 user: stephanie.gawroriski tags: wip-midlevel
02:12
Fixes for Runtime and Terminal shelves. check-in: 468ce76e8f user: stephanie.gawroriski tags: wip-midlevel
01:55
Some MLE call corrections; Enable JUnit XML and HTML reports in the tests (if this has an effect). check-in: 847b28b792 user: stephanie.gawroriski tags: wip-midlevel
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/MLERuntime.java.

14
15
16
17
18
19
20

21
22
23
24
25
26
27
...
133
134
135
136
137
138
139
140
141





142
143
144
145
146
147
148
149
150
151
152
153
154
155





156
157
158
159
160
161
162
...
192
193
194
195
196
197
198
199





200
201
202
203
204
205
206
import cc.squirreljme.jvm.mle.constants.BuiltInLocaleType;
import cc.squirreljme.jvm.mle.constants.VMDescriptionType;
import cc.squirreljme.jvm.mle.constants.VMStatisticType;
import cc.squirreljme.jvm.mle.constants.VMType;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.runtime.cldc.lang.LineEndingUtils;


/**
 * Functions for {@link MLERuntime}.
 *
 * @since 2020/06/18
 */
public enum MLERuntime
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			return __thread.machine._sysproperties.get(
				__thread.<String>asNativeObject(String.class, __args[0]));





		}
	},
	
	/** {@link RuntimeShelf#vmDescription(int)}. */
	VM_DESCRIPTION("vmDescription:(I)Ljava/lang/String;")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			switch ((int)__args[0])





			{
				case VMDescriptionType.EXECUTABLE_PATH:
					return null;
				
				case VMDescriptionType.OS_ARCH:
					return "springcoat/" + System.getProperty("os.arch");
					
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			switch ((int)__args[0])





			{
				case VMStatisticType.MEM_FREE:
					return Runtime.getRuntime().freeMemory();
					
				case VMStatisticType.MEM_MAX:
					return Runtime.getRuntime().maxMemory();
				







>







 







|
|
>
>
>
>
>













|
>
>
>
>
>







 







|
>
>
>
>
>







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
...
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import cc.squirreljme.jvm.mle.constants.BuiltInLocaleType;
import cc.squirreljme.jvm.mle.constants.VMDescriptionType;
import cc.squirreljme.jvm.mle.constants.VMStatisticType;
import cc.squirreljme.jvm.mle.constants.VMType;
import cc.squirreljme.runtime.cldc.SquirrelJME;
import cc.squirreljme.runtime.cldc.debug.Debugging;
import cc.squirreljme.runtime.cldc.lang.LineEndingUtils;
import cc.squirreljme.vm.springcoat.exceptions.SpringMLECallError;

/**
 * Functions for {@link MLERuntime}.
 *
 * @since 2020/06/18
 */
public enum MLERuntime
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			String key = __thread
				.<String>asNativeObject(String.class, __args[0]);
			
			if (key == null)
				throw new SpringMLECallError("Null key.");
			
			return __thread.machine._sysproperties.get(key);
		}
	},
	
	/** {@link RuntimeShelf#vmDescription(int)}. */
	VM_DESCRIPTION("vmDescription:(I)Ljava/lang/String;")
	{
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int index = (int)__args[0];
			if (index < 0 || index >= VMDescriptionType.NUM_TYPES)
				throw new SpringMLECallError(
					"Index out of range: " + index);
			
			switch (index)
			{
				case VMDescriptionType.EXECUTABLE_PATH:
					return null;
				
				case VMDescriptionType.OS_ARCH:
					return "springcoat/" + System.getProperty("os.arch");
					
................................................................................
		/**
		 * {@inheritDoc}
		 * @since 2020/06/18
		 */
		@Override
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			int index = (int)__args[0];
			if (index < 0 || index >= VMDescriptionType.NUM_TYPES)
				throw new SpringMLECallError(
					"Index out of range: " + index);
			
			switch (index)
			{
				case VMStatisticType.MEM_FREE:
					return Runtime.getRuntime().freeMemory();
					
				case VMStatisticType.MEM_MAX:
					return Runtime.getRuntime().maxMemory();
				

Changes to emulators/springcoat-vm/src/main/java/cc/squirreljme/vm/springcoat/MLETerminal.java.

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			try
			{
				MLETerminal.__fdOutput((int)__args[0]).flush();
				return 1;
			}
			catch (IllegalArgumentException| IOException e)
			{
				return -1;
			}
		}
	},
	
	/** {@link TerminalShelf#write(int, int)}. */
................................................................................
	}
	
	/**
	 * Returns the output stream for the given descriptor.
	 *
	 * @param __fd The file descriptor.
	 * @return The output stream for it.
	 * @throws IllegalArgumentException If the descriptor is not valid.
	 * @since 2020/06/13
	 */
	static OutputStream __fdOutput(int __fd)
		throws IllegalArgumentException
	{
		switch (__fd)
		{
			case StandardPipeType.STDOUT:	return System.out;
			case StandardPipeType.STDERR:	return System.err;
			
			default:
				throw new IllegalArgumentException("Unknown FD: " + __fd);
		}
	}
}







|







 







|



|







|



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
		public Object handle(SpringThreadWorker __thread, Object... __args)
		{
			try
			{
				MLETerminal.__fdOutput((int)__args[0]).flush();
				return 1;
			}
			catch (IllegalArgumentException|IOException e)
			{
				return -1;
			}
		}
	},
	
	/** {@link TerminalShelf#write(int, int)}. */
................................................................................
	}
	
	/**
	 * Returns the output stream for the given descriptor.
	 *
	 * @param __fd The file descriptor.
	 * @return The output stream for it.
	 * @throws SpringMLECallError If the descriptor is not valid.
	 * @since 2020/06/13
	 */
	static OutputStream __fdOutput(int __fd)
		throws SpringMLECallError
	{
		switch (__fd)
		{
			case StandardPipeType.STDOUT:	return System.out;
			case StandardPipeType.STDERR:	return System.err;
			
			default:
				throw new SpringMLECallError("Unknown FD: " + __fd);
		}
	}
}

Changes to modules/cldc-compact/src/main/java/cc/squirreljme/jvm/mle/RuntimeShelf.java.

11
12
13
14
15
16
17

18
19
20
21
22
23
24
..
84
85
86
87
88
89
90

91
92
93

94
95
96
97
98
99
100

101
102
103

104
105
106
107
108
109

110
111
112

113
114
115
116
117
118
119
120
121

import cc.squirreljme.jvm.mle.constants.LineEndingType;
import cc.squirreljme.jvm.mle.constants.BuiltInEncodingType;
import cc.squirreljme.jvm.mle.constants.BuiltInLocaleType;
import cc.squirreljme.jvm.mle.constants.VMDescriptionType;
import cc.squirreljme.jvm.mle.constants.VMStatisticType;
import cc.squirreljme.jvm.mle.constants.VMType;


/**
 * Run-time shelf which contains system information.
 *
 * @since 2020/06/09
 */
public final class RuntimeShelf
................................................................................
	public static native long nanoTime();
	
	/**
	 * Returns the system property for the given key, if there is one.
	 *
	 * @param __key The property key.
	 * @return The value of the system property or {@code null}.

	 * @since 2020/06/17
	 */
	public static native String systemProperty(String __key);

	
	/**
	 * Returns a special virtual machine description.
	 *
	 * @param __type The {@link VMDescriptionType}.
	 * @return The string for the given description or {@code null} if not
	 * set.

	 * @since 2020/06/17
	 */
	public static native String vmDescription(int __type);

	
	/**
	 * Returns a statistic of the virtual machine.
	 *
	 * @param __type The {@link VMStatisticType}.
	 * @return The value of the statistic, or {@code 0L} if not set.

	 * @since 2020/06/17
	 */
	public static native long vmStatistic(int __type);

	
	/**
	 * Returns the current {@link VMType}.
	 *
	 * @return The current {@link VMType}.
	 * @since 2020/06/16
	 */
	public static native int vmType();
}







>







 







>


|
>







>


|
>






>


|
>









11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

import cc.squirreljme.jvm.mle.constants.LineEndingType;
import cc.squirreljme.jvm.mle.constants.BuiltInEncodingType;
import cc.squirreljme.jvm.mle.constants.BuiltInLocaleType;
import cc.squirreljme.jvm.mle.constants.VMDescriptionType;
import cc.squirreljme.jvm.mle.constants.VMStatisticType;
import cc.squirreljme.jvm.mle.constants.VMType;
import cc.squirreljme.jvm.mle.exceptions.MLECallError;

/**
 * Run-time shelf which contains system information.
 *
 * @since 2020/06/09
 */
public final class RuntimeShelf
................................................................................
	public static native long nanoTime();
	
	/**
	 * Returns the system property for the given key, if there is one.
	 *
	 * @param __key The property key.
	 * @return The value of the system property or {@code null}.
	 * @throws MLECallError If {@code __key} is {@code null}.
	 * @since 2020/06/17
	 */
	public static native String systemProperty(String __key)
		throws MLECallError;
	
	/**
	 * Returns a special virtual machine description.
	 *
	 * @param __type The {@link VMDescriptionType}.
	 * @return The string for the given description or {@code null} if not
	 * set.
	 * @throws MLECallError If {@code __type} is not valid.
	 * @since 2020/06/17
	 */
	public static native String vmDescription(int __type)
		throws MLECallError;
	
	/**
	 * Returns a statistic of the virtual machine.
	 *
	 * @param __type The {@link VMStatisticType}.
	 * @return The value of the statistic, or {@code 0L} if not set.
	 * @throws MLECallError If {@code __type} is not valid.
	 * @since 2020/06/17
	 */
	public static native long vmStatistic(int __type)
		throws MLECallError;
	
	/**
	 * Returns the current {@link VMType}.
	 *
	 * @return The current {@link VMType}.
	 * @since 2020/06/16
	 */
	public static native int vmType();
}

Changes to modules/cldc-compact/src/test/java/squirreljme/mle/errors/TestRuntimeShelfInvalid.java.

43
44
45
46
47
48
49




50
51
52
53
54
55
56
57
			case 2:
				RuntimeShelf.vmStatistic(-1234);
				break;
			
			case 3:
				RuntimeShelf.vmStatistic(VMStatisticType.NUM_STATISTICS);
				break;




			
			default:
				return true;
		}
		
		return false;
	}
}







>
>
>
>








43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
			case 2:
				RuntimeShelf.vmStatistic(-1234);
				break;
			
			case 3:
				RuntimeShelf.vmStatistic(VMStatisticType.NUM_STATISTICS);
				break;
			
			case 4:
				RuntimeShelf.systemProperty(null);
				break;
			
			default:
				return true;
		}
		
		return false;
	}
}

Changes to modules/cldc-compact/src/test/java/squirreljme/mle/errors/TestTerminalShelfInvalid.java.

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69





70
71
72
73
74
75
76
77
				break;
			
			case 5:
				TerminalShelf.write(StandardPipeType.STDERR,
					new byte[12], 2, 12);
				break;
			
			case 7:
				TerminalShelf.write(StandardPipeType.STDERR,
					new byte[12], 0, 14);
				break;
			
			case 8:
				TerminalShelf.write(StandardPipeType.STDERR,
					new byte[12], 2, -14);
				break;





			
			default:
				return true;
		}
		
		return false;
	}
}







|




|



>
>
>
>
>








54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
				break;
			
			case 5:
				TerminalShelf.write(StandardPipeType.STDERR,
					new byte[12], 2, 12);
				break;
			
			case 6:
				TerminalShelf.write(StandardPipeType.STDERR,
					new byte[12], 0, 14);
				break;
			
			case 7:
				TerminalShelf.write(StandardPipeType.STDERR,
					new byte[12], 2, -14);
				break;
			
			case 8:
				TerminalShelf.write(-1,
					new byte[12], 0, 12);
				break;
			
			default:
				return true;
		}
		
		return false;
	}
}

Changes to modules/cldc-compact/src/test/resources/squirreljme/mle/errors/TestRuntimeShelfInvalid.in.

1
result: int:4
|
1
result: int:5