maxstack 5;
maxlocals 3;
aload_0;
dload_1;
dload_1;
invokespecial Rectangle :: (double, double): void;
return;
end;
% ---------------------------------------------- ---------------%
% ---------------------------------------------- ---------------%
% файл MainClass.jsm
public class MainClass;
methods;
public (): void;
maxstack 1;
maxlocals 1;
aload_0;
invokespecial java.lang.Object :: (): void;
return;
end;
public static main (java.lang.String []): void;
maxstack 8;
maxlocals 7;
iconst_3;
anewarray Figure;
astore_1;
aload_1;
iconst_0;
new Circle;
dup;
ldc2_w double 10;
invokespecial Circle :: (double): void;
aastore;
aload_1;
iconst_1;
new Rectangle;
dup;
dconst_1;
ldc2_w double 2;
invokespecial Rectangle :: (double, double): void;
aastore;
aload_1;
iconst_2;
new Square;
dup;
ldc2_w double 3;
invokespecial Square :: (double): void;
aastore;
dconst_0;
dstore_2;
iconst_0;
istore 4;
l_50:
iload 4;
aload_1;
arraylength;
if_icmpge l_75;
dload_2;
aload_1;
iload 4;
aaload;
invokeinterface Figure :: getArea (): double, 1;
dadd;
dstore_2;
iinc 4, 1;
goto l_50;
l_75:
new java.io.BufferedReader;
dup;
new java.io.InputStreamReader;
dup;
getstatic java.lang.System :: in: java.io.InputStream;
invokespecial java.io.InputStreamReader :: (java.io.InputStream): void;
invokespecial java.io.BufferedReader :: (java.io.Reader): void;
astore 4;
l_50:
aload 4;
invokevirtual java.io.BufferedReader :: readLine (): java.lang.String;
invokestatic java.lang.Double :: parseDouble (java.lang.String): double;
dstore 5;
getstatic java.lang.System :: out: java.io.PrintStream;
dload 5;
dload_2;
dadd;
invokevirtual java.io.PrintStream :: println (double): void;
l_114:
goto l_127;
l_117:
astore 4;
getstatic java.lang.System :: out: java.io.PrintStream;
ldc string "Error";
invokevirtual java.io.PrintStream :: println (java.lang.String): void;
l_127:
return;
protected_blocks;
java.io.IOException l_75: l_114> l_117;
end;
% ---------------------------------------------- ---------------%
Дана програма функціонально еквівалентна наступному коду на Java (асемблерний варіант створений на основі дизасемблювати з допомогою утиліти javap Java-програми):
// --------------------------------------------- --------------//
public interface Figure {
double getArea ();
}
// --------------------------------------------- --------------//
// --------------------------------------------- --------------//
public class Circle implements Figure {
private double m_radius;
public Circle (double radius) {
if (radius <0)
throw new IllegalArgumentException ();
m_radius = radius;
}
public double getArea () {
return m_radius * m_radius * Math.PI;
}
}
// --------------------------------------------- --------------//
// --------------------------------------------- --------------//
public class Rectangle implements Figure {
private double m_a;
private double m_b;
public Rectangle (double a, double b) {
if (! ((a> = 0) && (b> = 0)))
throw new IllegalArgumentException ();
m_a = a;
m_b = b;
}
public double getArea () {
return m_a * m_b;
}
}
// --------------------------------------------- --------------//
// --------------------------------------------- --------------//
public class Square extends Rectangle {
public Square (double a) {
super (a, a);
}
}
// --------------------------------------------- --------------//
// --------------------------------------------- --------------//
import java.io. *;
public class MainClass {
public static void main (String [] args) {
Figure [] figures = new Figure [3];
figures [0] = new Circle (10);
figures [1] = new Rectangle (1, 2); ...