import java.lang.reflect.Field;

class Suhu {
    private double celcius;

    public Suhu(double celcius) {
        this.celcius = celcius;
    }

    public double fahrenheit() {
        return celcius * 9 / 5 + 32;
    }
}

public class AksesAman {
    public static void main(String[] args) throws Exception {
        // Pola aman 1: refleksi pada class milik kode sendiri
        Field celcius = Suhu.class.getDeclaredField("celcius");
        celcius.setAccessible(true);
        Suhu suhu = new Suhu(100);
        System.out.println("celcius    : " + celcius.getDouble(suhu));

        // Pola aman 2: pakai API publik, bukan internals pihak lain
        System.out.println("fahrenheit : " + suhu.fahrenheit());
        Integer kotak = 42;
        System.out.println("intValue   : " + kotak.intValue());

        // Introspeksi module tanpa membuka akses
        Module sendiri = Suhu.class.getModule();
        Module pustaka = Integer.class.getModule();
        System.out.println("module Suhu    : "
                + (sendiri.isNamed() ? sendiri.getName() : "(tanpa nama)"));
        System.out.println("module Integer : "
                + (pustaka.isNamed() ? pustaka.getName() : "(tanpa nama)"));
    }
}
