Scala cannot access object classes <p>I'm obviously missing something fundamental here. I have the following Scala Code:</p> <pre><code>package org.carlskii import java.io._ import java.security.cert.CertificateFactory import java.security.Security import org.bouncycastle.jce.provider._ object Main extends App { Security.addProvider(new BouncyCastleProvider) val provider = new BouncyCastleProvider val in = new FileInputStream("cert.cer") val certificateFactory = CertificateFactory.getInstance("X509", provider) val certificate = certificateFactory.generateCertificate(file) println(certificate.getClass) } </code></pre> <p>Which produces this:</p> <pre><code>class org.bouncycastle.jce.provider.X509CertificateObject </code></pre> <p>So I have a Bouncy Castle <code>X509CertificateObject</code> object. If I call the <code>certificate.getPublicKey</code> method it correctly returns the public key for the certificate. </p> <p>However if I call <code>certificate.getSerialNumber</code> it throws the following error:</p> <pre><code>error: value getSerialNumber is not a member of java.security.cert.Certificate println(certificate.getSerialNumber) </code></pre> <p>The interesting thing here is that Scala thinks it's a <code>java.security.cert.Certificate</code> and not an <code>org.bouncycastle.jce.provider.X509CertificateObject</code> object. Why is this the case?</p>