My Java Assignment 2

profilechoks
Assignment-3.zip

Specification.html

This assignment ties together assignment #1 and #2. Assignment #1 had you read the first part of the class file, up until the start of the constant pool. Assignment #2 had you read each type of constant pool entry. Assignment 3 has you read the whole constant pool + the access flags, this class, super class, and the interfaces. Again, look here for the structure: https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.1

I inadvertently forgot the ConstantPoolModule tests in assignment #2, so that is added in #3.

You will need to update the ClassFile to read more parts of the file, but I would do that after writing the rest of the classes. I suggest you try to pass the tests in this order:

1) ConstantPoolModuleTests

2) DefaultConstantPoolFactoryTests

3) ConstantPoolTests

4) InterfacePoolTests 

5) MissingConstantPoolCountTests

6) ShortConstantPoolCountTests

7) ClassFileTest

8) All of the tests in the "classes" tests directory.

The files in the "classes" test directory were created from the source files in the "classes.zip" file. What I did was compile the classes and then generate code to get the bytes and then generate the test files. That means that the data we are using came directly from the compiler. Dod you really think i made all of these tests by hand? :-) You can use programs to automate everything. YOU DO NOT NEED TO COMPILE OR EVEN LOOK AT THE FILES (it is a good idea to look at them).

As you go through the tests you will be able to start to see how a .java file is converted to a .class file, which is the other part of this set of assignments. You actually lear a lot about Java when you understand how the class file fits together.

Also, two things about the constant pool:

- the 0 index is always null

- for long and double they take up 2 slots, that means that the entry after them is null. 

Assignment 3.zip

Assignment 3/.DS_Store

__MACOSX/Assignment 3/._.DS_Store

Assignment 3/Assignment 3.iml

Assignment 3/.idea/uiDesigner.xml

Assignment 3/.idea/.gitignore

# Default ignored files /shelf/ /workspace.xml

Assignment 3/.idea/workspace.xml

1592102201333 1592102201333

Assignment 3/.idea/modules.xml

Assignment 3/.idea/misc.xml

Assignment 3/src/.DS_Store

__MACOSX/Assignment 3/src/._.DS_Store

Assignment 3/.idea/codeStyles/codeStyleConfig.xml

Assignment 3/.idea/libraries/org_hamcrest_hamcrest_2_2.xml

Assignment 3/src/test/.DS_Store

__MACOSX/Assignment 3/src/test/._.DS_Store

Assignment 3/src/main/.DS_Store

__MACOSX/Assignment 3/src/main/._.DS_Store

Assignment 3/src/test/ca/.DS_Store

__MACOSX/Assignment 3/src/test/ca/._.DS_Store

Assignment 3/src/main/ca/.DS_Store

__MACOSX/Assignment 3/src/main/ca/._.DS_Store

Assignment 3/src/test/ca/bcit/.DS_Store

__MACOSX/Assignment 3/src/test/ca/bcit/._.DS_Store

Assignment 3/src/main/ca/bcit/.DS_Store

__MACOSX/Assignment 3/src/main/ca/bcit/._.DS_Store

Assignment 3/src/test/ca/bcit/comp2526/ShortMagic1Tests.java

Assignment 3/src/test/ca/bcit/comp2526/ShortMagic1Tests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   ShortMagic1Tests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 4 bytes to be available, have: 1" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ByteUtils.java

Assignment 3/src/test/ca/bcit/comp2526/ByteUtils.java

package  ca . bcit . comp2526 ;

import  java . io . * ;

public   final   class   ByteUtils
{
     private   ByteUtils ()
     {
         throw   new   IllegalStateException ( "Do not create instances" );
     }

     public   static   DataInputStream  createStream ( final   byte []   ...  bytes )
         throws   IOException
     {
         try ( final   ByteArrayOutputStream  byteStream  =   new   ByteArrayOutputStream ())
         {
             final   byte []  allBytes ;

             for ( final   byte []  array  :  bytes )
             {
                byteStream . writeBytes ( array );
             }

            allBytes  =  byteStream . toByteArray ();

             return   new   DataInputStream ( new   ByteArrayInputStream ( allBytes ));
         }
     }

     public   static   byte []  byteToBytes ( final   byte  value )
             throws   IOException
     {
         final   ByteArrayOutputStream  byteStream ;

        byteStream  =   new   ByteArrayOutputStream ();

         try ( final  var stream  =   new   DataOutputStream ( byteStream ))
         {
             final   byte []  bytes ;

            stream . writeByte ( value );
            bytes  =  byteStream . toByteArray ();

             return  bytes ;
         }
     }

     public   static   byte []  unsignedByteToBytes ( final   int  value )
             throws   IOException
     {
         final   byte []  bytes ;

        bytes  =  byteToBytes (( byte ) value );

         return  bytes ;
     }

     public   static   byte []  shortToBytes ( final   short  value )
             throws   IOException
     {
         final   ByteArrayOutputStream  byteStream ;

        byteStream  =   new   ByteArrayOutputStream ();

         try ( final  var stream  =   new   DataOutputStream ( byteStream ))
         {
             final   byte []  bytes ;

            stream . writeShort ( value );
            bytes  =  byteStream . toByteArray ();

             return  bytes ;
         }
     }

     public   static   byte []  unsignedShortToBytes ( final   int  value )
             throws   IOException
     {
         final   byte []  bytes ;

        bytes  =  shortToBytes (( short ) value );

         return  bytes ;
     }

     public   static   byte []  intToBytes ( final   int  value )
             throws   IOException
     {
         final   ByteArrayOutputStream  byteStream ;

        byteStream  =   new   ByteArrayOutputStream ();

         try ( final  var stream  =   new   DataOutputStream ( byteStream ))
         {
             final   byte []  bytes ;

            stream . writeInt ( value );
            bytes  =  byteStream . toByteArray ();

             return  bytes ;
         }
     }

     public   static   byte []  unsignedIntToBytes ( final   long  value )
             throws   IOException
     {
         final   byte []  bytes ;

        bytes  =  intToBytes (( int ) value );

         return  bytes ;
     }

     public   static   byte []  longToBytes ( final   long  value )
             throws   IOException
     {
         final   ByteArrayOutputStream  byteStream ;

        byteStream  =   new   ByteArrayOutputStream ();

         try ( final  var stream  =   new   DataOutputStream ( byteStream ))
         {
             final   byte []  bytes ;

            stream . writeLong ( value );
            bytes  =  byteStream . toByteArray ();

             return  bytes ;
         }
     }

     public   static   byte []  floatToBytes ( final   float  value )
             throws   IOException
     {
         final   ByteArrayOutputStream  byteStream ;

        byteStream  =   new   ByteArrayOutputStream ();

         try ( final  var stream  =   new   DataOutputStream ( byteStream ))
         {
             final   byte []  bytes ;

            stream . writeFloat ( value );
            bytes  =  byteStream . toByteArray ();

             return  bytes ;
         }
     }

     public   static   byte []  doubleToBytes ( final   double  value )
             throws   IOException
     {
         final   ByteArrayOutputStream  byteStream ;

        byteStream  =   new   ByteArrayOutputStream ();

         try ( final  var stream  =   new   DataOutputStream ( byteStream ))
         {
             final   byte []  bytes ;

            stream . writeDouble ( value );
            bytes  =  byteStream . toByteArray ();

             return  bytes ;
         }
     }

     public   static   byte []  stringToBytes ( final   String  value )
             throws   IOException
     {
         final   ByteArrayOutputStream  byteStream ;

        byteStream  =   new   ByteArrayOutputStream ();

         try ( final  var stream  =   new   DataOutputStream ( byteStream ))
         {
             final   byte []  bytes ;

            stream . writeBytes ( value );
            bytes  =  byteStream . toByteArray ();

             return  bytes ;
         }
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ShortMinorTests.java

Assignment 3/src/test/ca/bcit/comp2526/ShortMinorTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   ShortMinorTests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 2 bytes to be available, have: 1" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/.DS_Store

__MACOSX/Assignment 3/src/test/ca/bcit/comp2526/._.DS_Store

Assignment 3/src/test/ca/bcit/comp2526/MissingConstantPoolCountTests.java

Assignment 3/src/test/ca/bcit/comp2526/MissingConstantPoolCountTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   MissingConstantPoolCountTests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 2 bytes to be available, have: 0" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ShortMajorTests.java

Assignment 3/src/test/ca/bcit/comp2526/ShortMajorTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   ShortMajorTests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 2 bytes to be available, have: 1" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/DefaultConstantPoolEntryFactoryTest.java

Assignment 3/src/test/ca/bcit/comp2526/DefaultConstantPoolEntryFactoryTest.java

package  ca . bcit . comp2526 ;

import  ca . bcit . comp2526 . constantpool . * ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . hamcrest . Matchers . equalTo ;
import   static  org . hamcrest . Matchers . instanceOf ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   DefaultConstantPoolEntryFactoryTest
{
     private   DefaultConstantPoolEntryFactory  factory ;

    @ BeforeAll
     public   void  setup ()
     {
        factory  =   new   DefaultConstantPoolEntryFactory ();
     }

    @ Test
     public   void  testCreateConstantPoolEntryClass ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryClass  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . CLASS ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 3 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . CLASS )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryClass . class ));
        specificEntry  =   ( ConstantPoolEntryClass ) entry ;
        assertThat ( specificEntry . getNameIndex (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryDouble ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryDouble  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . DOUBLE ,
                 ByteUtils . createStream ( ByteUtils . doubleToBytes ( 123.456 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . DOUBLE )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryDouble . class ));
        specificEntry  =   ( ConstantPoolEntryDouble ) entry ;
        assertThat ( specificEntry . getValue (),  equalTo ( 123.456 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryDynamic ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryDynamic  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . DYNAMIC ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 2 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . DYNAMIC )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryDynamic . class ));
        specificEntry  =   ( ConstantPoolEntryDynamic ) entry ;
        assertThat ( specificEntry . getBootstrapMethodAttrIndex (),  equalTo ( 1 ));
        assertThat ( specificEntry . getNameAndTypeIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryField ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryField  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . FIELD ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 3 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . FIELD )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryField . class ));
        specificEntry  =   ( ConstantPoolEntryField ) entry ;
        assertThat ( specificEntry . getClassIndex (),  equalTo ( 2 ));
        assertThat ( specificEntry . getNameAndTypeIndex (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryFloat ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryFloat  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . FLOAT ,
                 ByteUtils . createStream ( ByteUtils . floatToBytes ( 234.567f )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . FLOAT )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryFloat . class ));
        specificEntry  =   ( ConstantPoolEntryFloat ) entry ;
        assertThat ( specificEntry . getValue (),  equalTo ( 234.567f ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryInteger ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryInteger  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . INTEGER ,
                 ByteUtils . createStream ( ByteUtils . intToBytes ( 12 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . INTEGER )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryInteger . class ));
        specificEntry  =   ( ConstantPoolEntryInteger ) entry ;
        assertThat ( specificEntry . getValue (),  equalTo ( 12 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryInterfaceMethod ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryInterfaceMethod  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . INTERFACE_METHOD ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 4 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . INTERFACE_METHOD )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryInterfaceMethod . class ));
        specificEntry  =   ( ConstantPoolEntryInterfaceMethod ) entry ;
        assertThat ( specificEntry . getClassIndex (),  equalTo ( 1 ));
        assertThat ( specificEntry . getNameAndTypeIndex (),  equalTo ( 4 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryInvokeDynamic ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryInvokeDynamic  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . INVOKE_DYNAMIC ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 3 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . INVOKE_DYNAMIC )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryInvokeDynamic . class ));
        specificEntry  =   ( ConstantPoolEntryInvokeDynamic ) entry ;
        assertThat ( specificEntry . getBootstrapMethodAttrIndex (),  equalTo ( 2 ));
        assertThat ( specificEntry . getNameAndTypeIndex (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryLong ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryLong  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . LONG ,
                 ByteUtils . createStream ( ByteUtils . longToBytes ( 9998L )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . LONG )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryLong . class ));
        specificEntry  =   ( ConstantPoolEntryLong ) entry ;
        assertThat ( specificEntry . getValue (),  equalTo ( 9998L ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryMethodHandle ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryMethodHandle  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . METHOD_HANDLE ,
                 ByteUtils . createStream ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . INVOKE_INTERFACE . getType ()),   ByteUtils . unsignedShortToBytes ( 1 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . METHOD_HANDLE )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryMethodHandle . class ));
        specificEntry  =   ( ConstantPoolEntryMethodHandle ) entry ;
        assertThat ( specificEntry . getReferenceKind (),  equalTo ( MethodHandleKind . INVOKE_INTERFACE ));
        assertThat ( specificEntry . getReferenceIndex (),  equalTo ( 1 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryMethod ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryMethod  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . METHOD ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 3 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . METHOD )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryMethod . class ));
        specificEntry  =   ( ConstantPoolEntryMethod ) entry ;
        assertThat ( specificEntry . getClassIndex (),  equalTo ( 1 ));
        assertThat ( specificEntry . getNameAndTypeIndex (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryMethodType ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryMethodType  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . METHOD_TYPE ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 2 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . METHOD_TYPE )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryMethodType . class ));
        specificEntry  =   ( ConstantPoolEntryMethodType ) entry ;
        assertThat ( specificEntry . getDescriptorIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryModule ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryModule  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . MODULE ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 1 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . MODULE )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryModule . class ));
        specificEntry  =   ( ConstantPoolEntryModule ) entry ;
        assertThat ( specificEntry . getNameIndex (),  equalTo ( 1 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryNameAndType ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryNameAndType  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . NAME_AND_TYPE ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 3 ),   ByteUtils . unsignedShortToBytes ( 4 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . NAME_AND_TYPE )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryNameAndType . class ));
        specificEntry  =   ( ConstantPoolEntryNameAndType ) entry ;
        assertThat ( specificEntry . getNameIndex (),  equalTo ( 3 ));
        assertThat ( specificEntry . getDescriptorIndex (),  equalTo ( 4 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryPackage ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryPackage  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . PACKAGE ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 3 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . PACKAGE )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryPackage . class ));
        specificEntry  =   ( ConstantPoolEntryPackage ) entry ;
        assertThat ( specificEntry . getNameIndex (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryString ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryString  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . STRING ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 3 )));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . STRING )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryString . class ));
        specificEntry  =   ( ConstantPoolEntryString ) entry ;
        assertThat ( specificEntry . getStringIndex (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testCreateConstantPoolEntryUTF8 ()
             throws   InvalidReferenceKindException ,
             InvalidConstantPoolIndexException ,
             NotEnoughDataException ,
             InvalidConstantPoolTagException ,
             IOException
     {
         final   ConstantPoolEntry  entry ;
         final   ConstantPoolEntryUTF8  specificEntry ;

        entry  =  factory . createConstantPoolEntry ( ConstantPoolType . UTF8 ,
                 ByteUtils . createStream ( ByteUtils . unsignedShortToBytes ( 5 ),   "World" . getBytes ()));
        assertThat ( entry . getType (),  equalTo (( ConstantPoolType . UTF8 )));
        assertThat ( entry ,  instanceOf ( ConstantPoolEntryUTF8 . class ));
        specificEntry  =   ( ConstantPoolEntryUTF8 ) entry ;
        assertThat ( specificEntry . getBytes (),  equalTo ( new   byte []   {   87 ,   111 ,   114 ,   108 ,   100   }));
        assertThat ( specificEntry . getString (),  equalTo ( "World" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/MissingMinorTests.java

Assignment 3/src/test/ca/bcit/comp2526/MissingMinorTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   MissingMinorTests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 2 bytes to be available, have: 0" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/MissingMajorTests.java

Assignment 3/src/test/ca/bcit/comp2526/MissingMajorTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   MissingMajorTests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 2 bytes to be available, have: 0" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ShortConstantPoolCountTests.java

Assignment 3/src/test/ca/bcit/comp2526/ShortConstantPoolCountTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   ShortConstantPoolCountTests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 2 bytes to be available, have: 1" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/TooLowMajorTests.java

Assignment 3/src/test/ca/bcit/comp2526/TooLowMajorTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   TooLowMajorTests
     extends   ClassFileTest
{
    @ Test
     public   void  majorTooLow1 ()
     {
         final   InvalidMajorVersionException  ex ;

        ex  =  assertThrows ( InvalidMajorVersionException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2C   }));
        assertThat ( ex . getMessage (),  equalTo ( "Major number must be between 45 and 55, was: 44" ));
     }

    @ Test
     public   void  majorTooLow2 ()
     {
         final   InvalidMajorVersionException  ex ;

        ex  =  assertThrows ( InvalidMajorVersionException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2B   }));
        assertThat ( ex . getMessage (),  equalTo ( "Major number must be between 45 and 55, was: 43" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ClassFileTest.java

Assignment 3/src/test/ca/bcit/comp2526/ClassFileTest.java

package  ca . bcit . comp2526 ;

import  ca . bcit . comp2526 . constantpool . * ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . CoreMatchers . instanceOf ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . hamcrest . Matchers . closeTo ;

public   abstract   class   ClassFileTest
{
     protected   ClassFile  createClassFile ( final   byte []  bytes )
         throws   IOException ,
                NotEnoughDataException ,
                ClassFileException
     {
         try ( final   DataInputStream  stream  =   new   DataInputStream ( new   ByteArrayInputStream ( bytes )))
         {
             final   ClassFile  classFile ;

            classFile  =   new   ClassFile ( stream );

             return  classFile ;
         }
     }

     protected   void  checkClass ( final   ConstantPoolEntry  entry ,
                               final   int                nameIndex )
     {
         final   ConstantPoolEntryClass  classEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryClass . class ));
        classEntry  =   ( ConstantPoolEntryClass ) entry ;
        assertThat ( classEntry . getNameIndex (),  equalTo ( nameIndex ));
     }

     protected   void  checkDouble ( final   ConstantPoolEntry  entry ,
                                final   double             value )
     {
         final   ConstantPoolEntryDouble  doubleEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryDouble . class ));
        doubleEntry  =   ( ConstantPoolEntryDouble )  entry ;
        assertThat ( doubleEntry . getValue (),  closeTo ( value ,   0.0001 ));
     }

     protected   void  checkDynamic ( final   ConstantPoolEntry  entry ,
                                 final   int                bootstrapMethodAttrIndex ,
                                 final   int                nameAndTypeIndex )
     {
         final   ConstantPoolEntryDynamic  dynamicEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryDynamic . class ));
        dynamicEntry  =   ( ConstantPoolEntryDynamic )  entry ;
        assertThat ( dynamicEntry . getBootstrapMethodAttrIndex (),  equalTo ( bootstrapMethodAttrIndex ));
        assertThat ( dynamicEntry . getNameAndTypeIndex (),  equalTo ( nameAndTypeIndex ));
     }

     protected   void  checkField ( final   ConstantPoolEntry  entry ,
                               final   int                classIndex ,
                               final   int                nameAndTypeIndex )
     {
         final   ConstantPoolEntryField  fieldEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryField . class ));
        fieldEntry  =   ( ConstantPoolEntryField )  entry ;
        assertThat ( fieldEntry . getClassIndex (),  equalTo ( classIndex ));
        assertThat ( fieldEntry . getNameAndTypeIndex (),  equalTo ( nameAndTypeIndex ));
     }

     protected   void  checkFloat ( final   ConstantPoolEntry  entry ,
                               final   float              value )
     {
         final   ConstantPoolEntryFloat  floatEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryFloat . class ));
        floatEntry  =   ( ConstantPoolEntryFloat )  entry ;
        assertThat (( double ) floatEntry . getValue (),  closeTo (( double ) value ,   0.0001f ));
     }

     protected   void  checkInteger ( final   ConstantPoolEntry  entry ,
                                 final   int                value )
     {
         final   ConstantPoolEntryInteger  integerEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryInteger . class ));
        integerEntry  =   ( ConstantPoolEntryInteger ) entry ;
        assertThat ( integerEntry . getValue (),  equalTo ( value ));
     }

     protected   void  checkInvokeDynamic ( final   ConstantPoolEntry  entry ,
                                       final   int                bootstringMethodAttrInde ,
                                       final   int                nameAndTypeIndex )
     {
         final   ConstantPoolEntryInvokeDynamic  dynamicEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryInvokeDynamic . class ));
        dynamicEntry  =   ( ConstantPoolEntryInvokeDynamic ) entry ;
        assertThat ( dynamicEntry . getBootstrapMethodAttrIndex (),  equalTo ( bootstringMethodAttrInde ));
        assertThat ( dynamicEntry . getNameAndTypeIndex (),  equalTo ( nameAndTypeIndex ));
     }

     protected   void  checkInterfaceMethod ( final   ConstantPoolEntry  entry ,
                                         final   int                classIndex ,
                                         final   int                nameAndTypeIndex )
     {
         final   ConstantPoolEntryInterfaceMethod  methodEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryInterfaceMethod . class ));
        methodEntry  =   ( ConstantPoolEntryInterfaceMethod ) entry ;
        assertThat ( methodEntry . getClassIndex (),  equalTo ( classIndex ));
        assertThat ( methodEntry . getNameAndTypeIndex (),  equalTo ( nameAndTypeIndex ));
     }

     protected   void  checkLong ( final   ConstantPoolEntry  entry ,
                              final   long               value )
     {
         final   ConstantPoolEntryLong  longEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryLong . class ));
        longEntry  =   ( ConstantPoolEntryLong ) entry ;
        assertThat ( longEntry . getValue (),  equalTo ( value ));
     }

     protected   void  checkMethod ( final   ConstantPoolEntry  entry ,
                                final   int                classIndex ,
                                final   int                nameAndTypeIndex )
     {
         final   ConstantPoolEntryMethod  methodEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryMethod . class ));
        methodEntry  =   ( ConstantPoolEntryMethod ) entry ;
        assertThat ( methodEntry . getClassIndex (),  equalTo ( classIndex ));
        assertThat ( methodEntry . getNameAndTypeIndex (),  equalTo ( nameAndTypeIndex ));
     }

     protected   void  checkMethodHandle ( final   ConstantPoolEntry  entry ,
                                      final   MethodHandleKind   referenceKind ,
                                      final   int                referenceIndex )
     {
         final   ConstantPoolEntryMethodHandle  methodHandleEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryMethodHandle . class ));
        methodHandleEntry  =   ( ConstantPoolEntryMethodHandle ) entry ;
        assertThat ( methodHandleEntry . getReferenceKind (),  equalTo ( referenceKind ));
        assertThat ( methodHandleEntry . getReferenceIndex (),  equalTo ( referenceIndex ));
     }

     protected   void  checkMethodType ( final   ConstantPoolEntry  entry ,
                                    final   int               descriptorIndex )
     {
         final   ConstantPoolEntryMethodType  methodTypeEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryMethodType . class ));
        methodTypeEntry  =   ( ConstantPoolEntryMethodType ) entry ;
        assertThat ( methodTypeEntry . getDescriptorIndex (),  equalTo ( descriptorIndex ));
     }

     protected   void  checkModule ( final   ConstantPoolEntry  entry ,
                                final   int                nameIndex )
     {
         final   ConstantPoolEntryModule  moduleEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryModule . class ));
        moduleEntry  =   ( ConstantPoolEntryModule ) entry ;
        assertThat ( moduleEntry . getNameIndex (),  equalTo ( nameIndex ));
     }

     protected   void  checkNameAndType ( final   ConstantPoolEntry  entry ,
                                     final   int                nameIndex ,
                                     final   int                descriptorIndex )
     {
         final   ConstantPoolEntryNameAndType  nameAndType ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryNameAndType . class ));
        nameAndType  =   ( ConstantPoolEntryNameAndType )  entry ;
        assertThat ( nameAndType . getNameIndex (),  equalTo ( nameIndex ));
        assertThat ( nameAndType . getDescriptorIndex (),  equalTo ( descriptorIndex ));
     }

     protected   void  checkPackage ( final   ConstantPoolEntry  entry ,
                                 final   int                nameIndex )
     {
         final   ConstantPoolEntryPackage  packageEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryPackage . class ));
        packageEntry  =   ( ConstantPoolEntryPackage ) entry ;
        assertThat ( packageEntry . getNameIndex (),  equalTo ( nameIndex ));
     }

     protected   void  checkString ( final   ConstantPoolEntry  entry ,
                                final   int                stringIndex )
     {
         final   ConstantPoolEntryString  stringEntry ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryString . class ));
        stringEntry  =   ( ConstantPoolEntryString ) entry ;
        assertThat ( stringEntry . getStringIndex (),  equalTo ( stringIndex ));
     }

     protected   void  checkUTF8 ( final   ConstantPoolEntry  entry ,
                              final   String             str )
     {
         final   ConstantPoolEntryUTF8  utf8 ;

        assertThat ( entry ,  instanceOf ( ConstantPoolEntryUTF8 . class ));
        utf8  =   ( ConstantPoolEntryUTF8 ) entry ;
        assertThat ( utf8 . getString (),  equalTo ( str ));
        assertThat ( utf8 . getBytes (),  equalTo ( str . getBytes ()));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/InterfacePoolTest.java

Assignment 3/src/test/ca/bcit/comp2526/InterfacePoolTest.java

package  ca . bcit . comp2526 ;

import  ca . bcit . comp2526 . constantpool . * ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . hamcrest . Matchers . * ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   InterfacePoolTest
{
     private   InterfacePool  poolA ;
     private   InterfacePool  poolB ;
     private   InterfacePool  poolC ;
     private   InterfacePool  poolD ;

    @ BeforeAll
     public   void  createClassFile ()
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException ,
             InvalidReferenceKindException ,
             InvalidConstantPoolTagException
     {
        poolA  =  createInterfacePool ( new   byte []   {   ( byte ) 0x00 ,   ( byte ) 0x00   });
        poolB  =  createInterfacePool ( new   byte []   {   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08   });
        poolC  =  createInterfacePool ( new   byte []   {   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03   });
        poolD  =  createInterfacePool ( new   byte []   {   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04   });
     }

     protected   InterfacePool  createInterfacePool ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException
     {
         try ( final   DataInputStream  stream  =   new   DataInputStream ( new   ByteArrayInputStream ( bytes )))
         {
             final   InterfacePool  interfacePool ;

            interfacePool  =   new   InterfacePool ( stream );

             return  interfacePool ;
         }
     }

    @ Test
     public   void  testGetCount ()
     {
        assertThat ( poolA . getNumberOfEntries (),  equalTo ( 0 ));
        assertThat ( poolB . getNumberOfEntries (),  equalTo ( 5 ));
        assertThat ( poolC . getNumberOfEntries (),  equalTo ( 1 ));
        assertThat ( poolD . getNumberOfEntries (),  equalTo ( 1 ));
     }

    @ Test
     public   void  testPoolB ()
     {
        testEntry ( poolB ,   0 ,   4 );
        testEntry ( poolB ,   1 ,   5 );
        testEntry ( poolB ,   2 ,   6 );
        testEntry ( poolB ,   3 ,   7 );
        testEntry ( poolB ,   4 ,   8 );
     }

    @ Test
     public   void  testPoolC ()
     {
        testEntry ( poolC ,   0 ,   3 );
     }

    @ Test
     public   void  testPoolD ()
     {
        testEntry ( poolD ,   0 ,   4 );
     }

     private   void  testEntry ( final   InterfacePool  pool ,
                            final   int  index ,
                            final   int  expected )
     {
         final   int  actual ;

        actual  =  pool . getInterface ( index );
        assertThat ( actual ,  equalTo ( expected ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ShortMagic3Tests.java

Assignment 3/src/test/ca/bcit/comp2526/ShortMagic3Tests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   ShortMagic3Tests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 4 bytes to be available, have: 3" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/BadMagicTests.java

Assignment 3/src/test/ca/bcit/comp2526/BadMagicTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   BadMagicTests
     extends   ClassFileTest
{
    @ Test
     public   void  badMagicNumber1 ()
     {
         final   InvalidMagicNumberException  ex ;

        ex  =  assertThrows ( InvalidMagicNumberException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBD   }));
        assertThat ( ex . getMessage (),  equalTo ( "Magic number must be 0xCAFEBABE, was: 0xCAFEBABD" ));
     }

    @ Test
     public   void  badMagicNumber2 ()
     {
         final   InvalidMagicNumberException  ex ;

        ex  =  assertThrows ( InvalidMagicNumberException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBC   }));
        assertThat ( ex . getMessage (),  equalTo ( "Magic number must be 0xCAFEBABE, was: 0xCAFEBABC" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ConstantPoolTest.java

Assignment 3/src/test/ca/bcit/comp2526/ConstantPoolTest.java

package  ca . bcit . comp2526 ;

import  ca . bcit . comp2526 . constantpool . * ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . hamcrest . Matchers . * ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolTest
{
     private   ConstantPool  poolA ;
     private   ConstantPool  poolB ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException ,
             InvalidReferenceKindException ,
             InvalidConstantPoolTagException
     {
         final   ConstantPoolEntryFactory  factory ;

        factory  =   new   DefaultConstantPoolEntryFactory ();
        poolA  =  createConstantPool ( factory ,   new   byte []   {   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2A ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x28 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x04 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0D   });
        poolB  =  createConstantPool ( factory ,   new   byte []   {   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x78 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x4A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x3A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x2A ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0xB5 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x11   });
     }

     protected   ConstantPool  createConstantPool ( final   ConstantPoolEntryFactory  factory ,
                                               final   byte []  bytes )
         throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException ,
             InvalidReferenceKindException ,
             InvalidConstantPoolTagException
     {
         try ( final   DataInputStream  stream  =   new   DataInputStream ( new   ByteArrayInputStream ( bytes )))
         {
             final   ConstantPool  constantPool ;

            constantPool  =   new   ConstantPool ( factory ,  stream );

             return  constantPool ;
         }
     }

    @ Test
     public   void  testGetCount ()
     {
        assertThat ( poolA . getNumberOfEntries (),  equalTo ( 16 ));
        assertThat ( poolB . getNumberOfEntries (),  equalTo ( 21 ));
     }

     /**
     * package ca.bcit.comp2526;
     *
     * public abstract class AbstractClassWithMethod
     * {
     *     public void foo()
     *     {
     *     }
     * }
     */
    @ Test
     public   void  testPoolA ()
     {
        testEntryNull ( poolA ,   0 ,   null );
        testEntryMethod ( poolA ,   1 ,   3 ,   14 );
        testEntryClass ( poolA ,   2 ,   15 );
        testEntryClass ( poolA ,   3 ,   16 );
        testEntryUTF8 ( poolA ,   4 ,   "<init>" );
        testEntryUTF8 ( poolA ,   5 ,   "()V" );
        testEntryUTF8 ( poolA ,   6 ,   "Code" );
        testEntryUTF8 ( poolA ,   7 ,   "LineNumberTable" );
        testEntryUTF8 ( poolA ,   8 ,   "LocalVariableTable" );
        testEntryUTF8 ( poolA ,   9 ,   "this" );
        testEntryUTF8 ( poolA ,   10 ,   "Lca/bcit/comp2526/AbstractClassWithMethod;" );
        testEntryUTF8 ( poolA ,   11 ,   "foo" );
        testEntryUTF8 ( poolA ,   12 ,   "SourceFile" );
        testEntryUTF8 ( poolA ,   13 ,   "AbstractClassWithMethod.java" );
        testEntryNameAndType ( poolA ,   14 ,   4 ,   5 );
        testEntryUTF8 ( poolA ,   15 ,   "ca/bcit/comp2526/AbstractClassWithMethod" );
        testEntryUTF8 ( poolA ,   16 ,   "java/lang/Object" );
     }

     /**
     * public class WithLong
     * {
     *     private long x = 13L;
     * }
     */
    @ Test
     public   void  testPoolB ()
     {
        testEntryNull ( poolB ,   0 ,   null );
        testEntryMethod ( poolB ,   1 ,   6 ,   18 );
        testEntryLong ( poolB ,   2 ,   13L );
        testEntryNull ( poolB ,   3 ,   null );
        testEntryField ( poolB ,   4 ,   5 ,   19 );
        testEntryClass ( poolB ,   5 ,   20 );
        testEntryClass ( poolB ,   6 ,   21 );
        testEntryUTF8 ( poolB ,   7 ,   "x" );
        testEntryUTF8 ( poolB ,   8 ,   "J" );
        testEntryUTF8 ( poolB ,   9 ,   "<init>" );
        testEntryUTF8 ( poolB ,   10 ,   "()V" );
        testEntryUTF8 ( poolB ,   11 ,   "Code" );
        testEntryUTF8 ( poolB ,   12 ,   "LineNumberTable" );
        testEntryUTF8 ( poolB ,   13 ,   "LocalVariableTable" );
        testEntryUTF8 ( poolB ,   14 ,   "this" );
        testEntryUTF8 ( poolB ,   15 ,   "Lca/bcit/comp2526/WithLong;" );
        testEntryUTF8 ( poolB ,   16 ,   "SourceFile" );
        testEntryUTF8 ( poolB ,   17 ,   "WithLong.java" );
        testEntryNameAndType ( poolB ,   18 ,   9 ,   10 );
        testEntryNameAndType ( poolB ,   19 ,   7 ,   8 );
        testEntryUTF8 ( poolB ,   20 ,   "ca/bcit/comp2526/WithLong" );
        testEntryUTF8 ( poolB ,   21 ,   "java/lang/Object" );
     }

     private   void  testEntryNull ( final   ConstantPool  pool ,
                                final   int           index ,
                                final   Class <?   extends   ConstantPoolEntry >  expected )
     {
         final   ConstantPoolEntry  entry ;

        entry  =  pool . getEntry ( index );
        assertThat ( entry ,  nullValue ());
     }

     private   < extends   ConstantPoolEntry >  T testEntry ( final   ConstantPool  pool ,
                                                       final   int           index ,
                                                       final   Class < T >      expected )
     {
         final   ConstantPoolEntry  entry ;

        entry  =  pool . getEntry ( index );
        assertThat ( entry ,  instanceOf ( expected ));

         return   ( T ) entry ;
     }

     private   void  testEntryMethod ( final   ConstantPool  pool ,
                                  final   int           index ,
                                  final   int           classIndex ,
                                  final   int           nameAndTypeIndex )
     {
         final   ConstantPoolEntryMethod  entry ;

        entry  =  testEntry ( pool ,  index ,   ConstantPoolEntryMethod . class );
        assertThat ( entry . getClassIndex (),  equalTo ( classIndex ));
        assertThat ( entry . getNameAndTypeIndex (),  equalTo ( nameAndTypeIndex ));
     }

     private   void  testEntryClass ( final   ConstantPool  pool ,
                                 final   int           index ,
                                 final   int           nameIndex )
     {
         final   ConstantPoolEntryClass  entry ;

        entry  =  testEntry ( pool ,  index ,   ConstantPoolEntryClass . class );
        assertThat ( entry . getNameIndex (),  equalTo ( nameIndex ));
     }

     private   void  testEntryUTF8 ( final   ConstantPool  pool ,
                                final   int           index ,
                                final   String        string )
     {
         final   ConstantPoolEntryUTF8  entry ;

        entry  =  testEntry ( pool ,  index ,   ConstantPoolEntryUTF8 . class );
        assertThat ( entry . getString (),  equalTo ( string ));
        assertThat ( entry . getBytes (),  equalTo ( string . getBytes ()));
     }

     private   void  testEntryNameAndType ( final   ConstantPool  pool ,
                                       final   int           index ,
                                       final   int           nameIndex ,
                                       final   int           descriptorIndex )
     {
         final   ConstantPoolEntryNameAndType  entry ;

        entry  =  testEntry ( pool ,  index ,   ConstantPoolEntryNameAndType . class );
        assertThat ( entry . getNameIndex (),  equalTo ( nameIndex ));
        assertThat ( entry . getDescriptorIndex (),  equalTo ( descriptorIndex ));
     }

     private   void  testEntryLong ( final   ConstantPool  pool ,
                                final   int           index ,
                                final   long          value )
     {
         final   ConstantPoolEntryLong  entry ;

        entry  =  testEntry ( pool ,  index ,   ConstantPoolEntryLong . class );
        assertThat ( entry . getValue (),  equalTo ( value ));
     }
     private   void  testEntryField ( final   ConstantPool  pool ,
                                 final   int           index ,
                                 final   int           classIndex ,
                                 final   int           nameAndTypeIndex )
     {
         final   ConstantPoolEntryField  entry ;

        entry  =  testEntry ( pool ,  index ,   ConstantPoolEntryField . class );
        assertThat ( entry . getClassIndex (),  equalTo ( classIndex ));
        assertThat ( entry . getNameAndTypeIndex (),  equalTo ( nameAndTypeIndex ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/MissingMagicTests.java

Assignment 3/src/test/ca/bcit/comp2526/MissingMagicTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   MissingMagicTests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []{}));
        assertThat ( ex . getMessage (),  equalTo ( "Require 4 bytes to be available, have: 0" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/TooHighMajorTests.java

Assignment 3/src/test/ca/bcit/comp2526/TooHighMajorTests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   TooHighMajorTests
     extends   ClassFileTest
{
    @ Test
     public   void  majorTooHigh1 ()
     {
         final   InvalidMajorVersionException  ex ;

        ex  =  assertThrows ( InvalidMajorVersionException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x38   }));
        assertThat ( ex . getMessage (),  equalTo ( "Major number must be between 45 and 55, was: 56" ));
     }
    @ Test
     public   void  majorTooHigh2 ()
     {
         final   InvalidMajorVersionException  ex ;

        ex  =  assertThrows ( InvalidMajorVersionException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x39   }));
        assertThat ( ex . getMessage (),  equalTo ( "Major number must be between 45 and 55, was: 57" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/ShortMagic2Tests.java

Assignment 3/src/test/ca/bcit/comp2526/ShortMagic2Tests.java

package  ca . bcit . comp2526 ;

import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   class   ShortMagic2Tests
     extends   ClassFileTest
{
    @ Test
     public   void  createClassFile ()
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE   }));
        assertThat ( ex . getMessage (),  equalTo ( "Require 4 bytes to be available, have: 2" ));
     }
}

Assignment 3/src/main/ca/bcit/comp2526/StreamUtils.java

Assignment 3/src/main/ca/bcit/comp2526/StreamUtils.java

package  ca . bcit . comp2526 ;

import  java . io . DataInputStream ;
import  java . io . IOException ;
import  java . io . InputStream ;

public   final   class   StreamUtils
{
     private   StreamUtils ()
     {
         throw   new   IllegalStateException ( "Do not instantiate" );
     }

     // this has issues, but will do for now
     private   static   void  checkAvailable ( final   InputStream  stream ,
                                        final   int          required )
         throws   IOException ,
                NotEnoughDataException
     {
         final   int  available ;

        available  =  stream . available ();

         if ( available  <  required )
         {
             throw   new   NotEnoughDataException ( required ,  available );
         }
     }

     public   static   void  readBytes ( final   DataInputStream  stream ,
                                  final   byte []           bytes )
         throws   IOException ,
                NotEnoughDataException
     {
         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,  bytes . length );

        stream . readFully ( bytes );
     }

     public   static   byte  readByte ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   byte  value ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   1 );
        value  =  stream . readByte ();

         return  value ;
     }

     public   static   short  readUnsignedByte ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   byte   value ;
         final   short  unsigned ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   1 );
        value     =  readByte ( stream );
         // Why isn't there a Byte.toUnsignedShort?!
        unsigned  =   ( short ) Byte . toUnsignedInt ( value );

         return  unsigned ;
     }

     public   static   short  readShort ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   short  value ;
         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   2 );
        value  =  stream . readShort ();

         return  value ;
     }

     public   static   int  readUnsignedShort ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   short  value ;
         final   int    unsigned ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   2 );
        value     =  readShort ( stream );
        unsigned  =   Short . toUnsignedInt ( value );

         return  unsigned ;
     }

     public   static   int  readInt ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   int  value ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   4 );
        value  =  stream . readInt ();

         return  value ;
     }

     public   static   long  readUnsignedInt ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   int  value ;
         final   long  unsigned ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   4 );
        value     =  readInt ( stream );
        unsigned  =   Integer . toUnsignedLong ( value );

         return  unsigned ;
     }

     public   static   float  readFloat ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   float  value ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   4 );
        value  =  stream . readFloat ();

         return  value ;
     }

     public   static   long  readLong ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   long  value ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   8 );
        value  =  stream . readLong ();

         return  value ;
     }

     public   static   double  readDouble ( final   DataInputStream  stream )
         throws   IOException ,
                NotEnoughDataException
     {
         final   double  value ;

         if ( stream  ==   null )
         {
             throw   new   IllegalArgumentException ( "stream cannot be null" );
         }

        checkAvailable ( stream ,   8 );
        value  =  stream . readDouble ();

         return  value ;
     }
}

Assignment 3/src/main/ca/bcit/comp2526/.DS_Store

__MACOSX/Assignment 3/src/main/ca/bcit/comp2526/._.DS_Store

Assignment 3/src/main/ca/bcit/comp2526/NotEnoughDataException.java

Assignment 3/src/main/ca/bcit/comp2526/NotEnoughDataException.java

package  ca . bcit . comp2526 ;

public   class   NotEnoughDataException
     extends   Exception
{
     private   final   int  expected ;
     private   final   int  actual ;

     public   NotEnoughDataException ( final   int  expected ,   final   int  actual )
     {
         super ( String . format ( "Require %d bytes to be available, have: %d" ,  expected ,  actual ));

         this . expected  =  expected ;
         this . actual    =  actual ;
     }

     public   int  getExpected ()
     {
         return  expected ;
     }

     public   int  getActual ()
     {
         return  actual ;
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyInterfaceTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyInterfaceTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   EmptyInterfaceTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x06 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x04   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 6 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkClass ( entry ,   5 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   6 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "EmptyInterface.java" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/EmptyInterface" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1537 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 1 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithIntTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithIntTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithIntTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0xBC ,   ( byte ) 0x61 ,   ( byte ) 0x4E ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x78 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x49 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x2A ,   ( byte ) 0x12 ,   ( byte ) 0x02 ,   ( byte ) 0xB5 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x10   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 20 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   5 ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkInteger ( entry ,   12345678 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkField ( entry ,   4 ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkClass ( entry ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "x" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "I" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithInt;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithInt.java" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   6 ,   7 );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithInt" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 4 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 5 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/AbstractClassWithMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/AbstractClassWithMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   AbstractClassWithMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2A ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x28 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x04 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0D   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 16 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   14 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   16 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/AbstractClassWithMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "AbstractClassWithMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   4 ,   5 );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/AbstractClassWithMethod" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1057 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassImplementsMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassImplementsMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ClassImplementsMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x1E ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x49 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x6D ,   ( byte ) 0x61 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x28 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x67 ,   ( byte ) 0x76 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2E ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x62 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x49 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x26 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x49 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x69 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0xBB ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x59 ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x4C ,   ( byte ) 0xBB ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x59 ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x4D ,   ( byte ) 0x2B ,   ( byte ) 0xB9 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0xB6 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x18   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 29 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   6 ,   25 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   25 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkInterfaceMethod ( entry ,   7 ,   27 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   27 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   28 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkClass ( entry ,   29 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/ClassImplementsMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "main" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "([Ljava/lang/String;)V" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "argv" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "[Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "a" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/InterfaceWithAbstractMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 22 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "b" );

        entry  =  classFile . getConstantPoolEntry ( 23 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 24 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ClassImplementsMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 25 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 26 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/ClassImplementsMethod" );

        entry  =  classFile . getConstantPoolEntry ( 27 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   15 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 28 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 29 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/InterfaceWithAbstractMethod" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 6 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 1 ));
        assertThat ( classFile . getInterface ( 0 ),  equalTo ( 7 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithIntConstantTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithIntConstantTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithIntConstantTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x58 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x49 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0xBC ,   ( byte ) 0x61 ,   ( byte ) 0x4E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x10   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 19 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "X" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "I" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ConstantValue" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkInteger ( entry ,   12345678 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithIntConstant;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithIntConstant.java" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithIntConstant" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyClassTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyClassTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   EmptyClassTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 15 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   13 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   14 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/EmptyClass;" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "EmptyClass.java" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   4 ,   5 );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/EmptyClass" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithFloatTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithFloatTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithFloatTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x04 ,   ( byte ) 0x41 ,   ( byte ) 0x31 ,   ( byte ) 0x99 ,   ( byte ) 0x9A ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x78 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x46 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x2A ,   ( byte ) 0x12 ,   ( byte ) 0x02 ,   ( byte ) 0xB5 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x10   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 20 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   5 ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkFloat ( entry ,   11.100000f );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkField ( entry ,   4 ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkClass ( entry ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "x" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "F" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithFloat;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithFloat.java" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   6 ,   7 );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithFloat" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 4 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 5 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/MHDTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/MHDTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  ca . bcit . comp2526 . constantpool . MethodHandleKind ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   MHDTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x4D ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x1F ,   ( byte ) 0x12 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x25 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x26 ,   ( byte ) 0x00 ,   ( byte ) 0x27 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x28 ,   ( byte ) 0x00 ,   ( byte ) 0x29 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x2A ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0x00 ,   ( byte ) 0x2D ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x2E ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x30 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x48 ,   ( byte ) 0x44 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x70 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x45 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x79 ,   ( byte ) 0x70 ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x24 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x3C ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x3E ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x53 ,   ( byte ) 0x69 ,   ( byte ) 0x67 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x27 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x3C ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x3E ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x64 ,   ( byte ) 0x61 ,   ( byte ) 0x24 ,   ( byte ) 0x70 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x45 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x24 ,   ( byte ) 0x30 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x4D ,   ( byte ) 0x48 ,   ( byte ) 0x44 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x42 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x70 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x73 ,   ( byte ) 0x0F ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x31 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x32 ,   ( byte ) 0x0F ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x33 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x34 ,   ( byte ) 0x00 ,   ( byte ) 0x35 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x36 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x38 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x3A ,   ( byte ) 0x00 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x49 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x20 ,   ( byte ) 0x3D ,   ( byte ) 0x20 ,   ( byte ) 0x25 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x3C ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x3D ,   ( byte ) 0x00 ,   ( byte ) 0x3E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x3F ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x40 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x48 ,   ( byte ) 0x44 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x41 ,   ( byte ) 0x00 ,   ( byte ) 0x42 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x43 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1F ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x66 ,   ( byte ) 0x75 ,   ( byte ) 0x6E ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x45 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x68 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x66 ,   ( byte ) 0x75 ,   ( byte ) 0x6E ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x79 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x2F ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x65 ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x6D ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x2F ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x65 ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x70 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x6C ,   ( byte ) 0x6E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x44 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x45 ,   ( byte ) 0x00 ,   ( byte ) 0x49 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x64 ,   ( byte ) 0x61 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x79 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x79 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x4B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x75 ,   ( byte ) 0x70 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0xCC ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x48 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x64 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x24 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x75 ,   ( byte ) 0x70 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x54 ,   ( byte ) 0x79 ,   ( byte ) 0x70 ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x54 ,   ( byte ) 0x79 ,   ( byte ) 0x70 ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x48 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x64 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x54 ,   ( byte ) 0x79 ,   ( byte ) 0x70 ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x6C ,   ( byte ) 0x53 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x4C ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x25 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x48 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x64 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x24 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x75 ,   ( byte ) 0x70 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x48 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x64 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x56 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x2B ,   ( byte ) 0xBA ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0xB9 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x10 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x3E ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0xB2 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x12 ,   ( byte ) 0x05 ,   ( byte ) 0x04 ,   ( byte ) 0xBD ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x59 ,   ( byte ) 0x03 ,   ( byte ) 0x2A ,   ( byte ) 0x53 ,   ( byte ) 0xB8 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0xB6 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x1E ,   ( byte ) 0x00 ,   ( byte ) 0x48 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x46 ,   ( byte ) 0x00 ,   ( byte ) 0x4A ,   ( byte ) 0x00 ,   ( byte ) 0x47 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x00 ,   ( byte ) 0x23 ,   ( byte ) 0x00 ,   ( byte ) 0x24   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 76 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   6 ,   31 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkInvokeDynamic ( entry ,   0 ,   37 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkInterfaceMethod ( entry ,   38 ,   39 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkField ( entry ,   40 ,   41 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkString ( entry ,   42 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   43 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkMethod ( entry ,   44 ,   45 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkMethod ( entry ,   46 ,   47 );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkClass ( entry ,   48 );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/MHD;" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "printElements" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/util/List;)V" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "strings" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/util/List;" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTypeTable" );

        entry  =  classFile . getConstantPoolEntry ( 22 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/util/List<Ljava/lang/String;>;" );

        entry  =  classFile . getConstantPoolEntry ( 23 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Signature" );

        entry  =  classFile . getConstantPoolEntry ( 24 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/util/List<Ljava/lang/String;>;)V" );

        entry  =  classFile . getConstantPoolEntry ( 25 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "lambda$printElements$0" );

        entry  =  classFile . getConstantPoolEntry ( 26 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/lang/String;)V" );

        entry  =  classFile . getConstantPoolEntry ( 27 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "item" );

        entry  =  classFile . getConstantPoolEntry ( 28 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 29 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 30 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "MHD.java" );

        entry  =  classFile . getConstantPoolEntry ( 31 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   10 ,   11 );

        entry  =  classFile . getConstantPoolEntry ( 32 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "BootstrapMethods" );

        entry  =  classFile . getConstantPoolEntry ( 33 );
        assertNotNull ( entry );
        checkMethodHandle ( entry ,   MethodHandleKind . INVOKE_STATIC ,   49 );

        entry  =  classFile . getConstantPoolEntry ( 34 );
        assertNotNull ( entry );
        checkMethodType ( entry ,   50 );

        entry  =  classFile . getConstantPoolEntry ( 35 );
        assertNotNull ( entry );
        checkMethodHandle ( entry ,   MethodHandleKind . INVOKE_STATIC ,   51 );

        entry  =  classFile . getConstantPoolEntry ( 36 );
        assertNotNull ( entry );
        checkMethodType ( entry ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 37 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   52 ,   53 );

        entry  =  classFile . getConstantPoolEntry ( 38 );
        assertNotNull ( entry );
        checkClass ( entry ,   54 );

        entry  =  classFile . getConstantPoolEntry ( 39 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   55 ,   56 );

        entry  =  classFile . getConstantPoolEntry ( 40 );
        assertNotNull ( entry );
        checkClass ( entry ,   57 );

        entry  =  classFile . getConstantPoolEntry ( 41 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   58 ,   59 );

        entry  =  classFile . getConstantPoolEntry ( 42 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Item = %s" );

        entry  =  classFile . getConstantPoolEntry ( 43 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 44 );
        assertNotNull ( entry );
        checkClass ( entry ,   60 );

        entry  =  classFile . getConstantPoolEntry ( 45 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   61 ,   62 );

        entry  =  classFile . getConstantPoolEntry ( 46 );
        assertNotNull ( entry );
        checkClass ( entry ,   63 );

        entry  =  classFile . getConstantPoolEntry ( 47 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   64 ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 48 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/MHD" );

        entry  =  classFile . getConstantPoolEntry ( 49 );
        assertNotNull ( entry );
        checkMethod ( entry ,   65 ,   66 );

        entry  =  classFile . getConstantPoolEntry ( 50 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/lang/Object;)V" );

        entry  =  classFile . getConstantPoolEntry ( 51 );
        assertNotNull ( entry );
        checkMethod ( entry ,   9 ,   67 );

        entry  =  classFile . getConstantPoolEntry ( 52 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "accept" );

        entry  =  classFile . getConstantPoolEntry ( 53 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()Ljava/util/function/Consumer;" );

        entry  =  classFile . getConstantPoolEntry ( 54 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/util/List" );

        entry  =  classFile . getConstantPoolEntry ( 55 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "forEach" );

        entry  =  classFile . getConstantPoolEntry ( 56 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/util/function/Consumer;)V" );

        entry  =  classFile . getConstantPoolEntry ( 57 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/System" );

        entry  =  classFile . getConstantPoolEntry ( 58 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "out" );

        entry  =  classFile . getConstantPoolEntry ( 59 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/io/PrintStream;" );

        entry  =  classFile . getConstantPoolEntry ( 60 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/String" );

        entry  =  classFile . getConstantPoolEntry ( 61 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "format" );

        entry  =  classFile . getConstantPoolEntry ( 62 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 63 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/io/PrintStream" );

        entry  =  classFile . getConstantPoolEntry ( 64 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "println" );

        entry  =  classFile . getConstantPoolEntry ( 65 );
        assertNotNull ( entry );
        checkClass ( entry ,   68 );

        entry  =  classFile . getConstantPoolEntry ( 66 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   69 ,   73 );

        entry  =  classFile . getConstantPoolEntry ( 67 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   25 ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 68 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/invoke/LambdaMetafactory" );

        entry  =  classFile . getConstantPoolEntry ( 69 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "metafactory" );

        entry  =  classFile . getConstantPoolEntry ( 70 );
        assertNotNull ( entry );
        checkClass ( entry ,   75 );

        entry  =  classFile . getConstantPoolEntry ( 71 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lookup" );

        entry  =  classFile . getConstantPoolEntry ( 72 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "InnerClasses" );

        entry  =  classFile . getConstantPoolEntry ( 73 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;" );

        entry  =  classFile . getConstantPoolEntry ( 74 );
        assertNotNull ( entry );
        checkClass ( entry ,   76 );

        entry  =  classFile . getConstantPoolEntry ( 75 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/invoke/MethodHandles$Lookup" );

        entry  =  classFile . getConstantPoolEntry ( 76 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/invoke/MethodHandles" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 9 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 6 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyFinalClassTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyFinalClassTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   EmptyFinalClassTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x31 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 15 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   13 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   14 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/EmptyFinalClass;" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "EmptyFinalClass.java" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   4 ,   5 );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/EmptyFinalClass" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 49 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyAbstractClassTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/EmptyAbstractClassTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   EmptyAbstractClassTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x25 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x23 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x45 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x74 ,   ( byte ) 0x79 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x04 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 15 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   13 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   14 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/EmptyAbstractClass;" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "EmptyAbstractClass.java" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   4 ,   5 );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/EmptyAbstractClass" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1057 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/AbstractClassWithFinalMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/AbstractClassWithFinalMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   AbstractClassWithFinalMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2D ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x04 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0E   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 18 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   16 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkClass ( entry ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/AbstractClassWithFinalMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "AbstractClassWithFinalMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   5 ,   6 );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/AbstractClassWithFinalMethod" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/InterfaceWithAbstractMethod" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1057 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 1 ));
        assertThat ( classFile . getInterface ( 0 ),  equalTo ( 4 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/InterfaceWithDefaultMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/InterfaceWithDefaultMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   InterfaceWithDefaultMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2D ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x06 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 13 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkClass ( entry ,   12 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   13 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/InterfaceWithDefaultMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "InterfaceWithDefaultMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/InterfaceWithDefaultMethod" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1537 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 1 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithDoubleConstantTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithDoubleConstantTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithDoubleConstantTests
     extends   ClassFileTest   {
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException   {
        classFile  =  createClassFile ( new   byte []{( byte )   0xCA ,   ( byte )   0xFE ,   ( byte )   0xBA ,   ( byte )   0xBE ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x37 ,   ( byte )   0x00 ,   ( byte )   0x15 ,   ( byte )   0x0A ,   ( byte )   0x00 ,   ( byte )   0x03 ,   ( byte )   0x00 ,   ( byte )   0x12 ,   ( byte )   0x07 ,   ( byte )   0x00 ,   ( byte )   0x13 ,   ( byte )   0x07 ,   ( byte )   0x00 ,   ( byte )   0x14 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x58 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x44 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x0D ,   ( byte )   0x43 ,   ( byte )   0x6F ,   ( byte )   0x6E ,   ( byte )   0x73 ,   ( byte )   0x74 ,   ( byte )   0x61 ,   ( byte )   0x6E ,   ( byte )   0x74 ,   ( byte )   0x56 ,   ( byte )   0x61 ,   ( byte )   0x6C ,   ( byte )   0x75 ,   ( byte )   0x65 ,   ( byte )   0x06 ,   ( byte )   0x40 ,   ( byte )   0x26 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x06 ,   ( byte )   0x3C ,   ( byte )   0x69 ,   ( byte )   0x6E ,   ( byte )   0x69 ,   ( byte )   0x74 ,   ( byte )   0x3E ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x03 ,   ( byte )   0x28 ,   ( byte )   0x29 ,   ( byte )   0x56 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x04 ,   ( byte )   0x43 ,   ( byte )   0x6F ,   ( byte )   0x64 ,   ( byte )   0x65 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x0F ,   ( byte )   0x4C ,   ( byte )   0x69 ,   ( byte )   0x6E ,   ( byte )   0x65 ,   ( byte )   0x4E ,   ( byte )   0x75 ,   ( byte )   0x6D ,   ( byte )   0x62 ,   ( byte )   0x65 ,   ( byte )   0x72 ,   ( byte )   0x54 ,   ( byte )   0x61 ,   ( byte )   0x62 ,   ( byte )   0x6C ,   ( byte )   0x65 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x12 ,   ( byte )   0x4C ,   ( byte )   0x6F ,   ( byte )   0x63 ,   ( byte )   0x61 ,   ( byte )   0x6C ,   ( byte )   0x56 ,   ( byte )   0x61 ,   ( byte )   0x72 ,   ( byte )   0x69 ,   ( byte )   0x61 ,   ( byte )   0x62 ,   ( byte )   0x6C ,   ( byte )   0x65 ,   ( byte )   0x54 ,   ( byte )   0x61 ,   ( byte )   0x62 ,   ( byte )   0x6C ,   ( byte )   0x65 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x04 ,   ( byte )   0x74 ,   ( byte )   0x68 ,   ( byte )   0x69 ,   ( byte )   0x73 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x25 ,   ( byte )   0x4C ,   ( byte )   0x63 ,   ( byte )   0x61 ,   ( byte )   0x2F ,   ( byte )   0x62 ,   ( byte )   0x63 ,   ( byte )   0x69 ,   ( byte )   0x74 ,   ( byte )   0x2F ,   ( byte )   0x63 ,   ( byte )   0x6F ,   ( byte )   0x6D ,   ( byte )   0x70 ,   ( byte )   0x32 ,   ( byte )   0x35 ,   ( byte )   0x32 ,   ( byte )   0x36 ,   ( byte )   0x2F ,   ( byte )   0x57 ,   ( byte )   0x69 ,   ( byte )   0x74 ,   ( byte )   0x68 ,   ( byte )   0x44 ,   ( byte )   0x6F ,   ( byte )   0x75 ,   ( byte )   0x62 ,   ( byte )   0x6C ,   ( byte )   0x65 ,   ( byte )   0x43 ,   ( byte )   0x6F ,   ( byte )   0x6E ,   ( byte )   0x73 ,   ( byte )   0x74 ,   ( byte )   0x61 ,   ( byte )   0x6E ,   ( byte )   0x74 ,   ( byte )   0x3B ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x0A ,   ( byte )   0x53 ,   ( byte )   0x6F ,   ( byte )   0x75 ,   ( byte )   0x72 ,   ( byte )   0x63 ,   ( byte )   0x65 ,   ( byte )   0x46 ,   ( byte )   0x69 ,   ( byte )   0x6C ,   ( byte )   0x65 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x17 ,   ( byte )   0x57 ,   ( byte )   0x69 ,   ( byte )   0x74 ,   ( byte )   0x68 ,   ( byte )   0x44 ,   ( byte )   0x6F ,   ( byte )   0x75 ,   ( byte )   0x62 ,   ( byte )   0x6C ,   ( byte )   0x65 ,   ( byte )   0x43 ,   ( byte )   0x6F ,   ( byte )   0x6E ,   ( byte )   0x73 ,   ( byte )   0x74 ,   ( byte )   0x61 ,   ( byte )   0x6E ,   ( byte )   0x74 ,   ( byte )   0x2E ,   ( byte )   0x6A ,   ( byte )   0x61 ,   ( byte )   0x76 ,   ( byte )   0x61 ,   ( byte )   0x0C ,   ( byte )   0x00 ,   ( byte )   0x09 ,   ( byte )   0x00 ,   ( byte )   0x0A ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x23 ,   ( byte )   0x63 ,   ( byte )   0x61 ,   ( byte )   0x2F ,   ( byte )   0x62 ,   ( byte )   0x63 ,   ( byte )   0x69 ,   ( byte )   0x74 ,   ( byte )   0x2F ,   ( byte )   0x63 ,   ( byte )   0x6F ,   ( byte )   0x6D ,   ( byte )   0x70 ,   ( byte )   0x32 ,   ( byte )   0x35 ,   ( byte )   0x32 ,   ( byte )   0x36 ,   ( byte )   0x2F ,   ( byte )   0x57 ,   ( byte )   0x69 ,   ( byte )   0x74 ,   ( byte )   0x68 ,   ( byte )   0x44 ,   ( byte )   0x6F ,   ( byte )   0x75 ,   ( byte )   0x62 ,   ( byte )   0x6C ,   ( byte )   0x65 ,   ( byte )   0x43 ,   ( byte )   0x6F ,   ( byte )   0x6E ,   ( byte )   0x73 ,   ( byte )   0x74 ,   ( byte )   0x61 ,   ( byte )   0x6E ,   ( byte )   0x74 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x10 ,   ( byte )   0x6A ,   ( byte )   0x61 ,   ( byte )   0x76 ,   ( byte )   0x61 ,   ( byte )   0x2F ,   ( byte )   0x6C ,   ( byte )   0x61 ,   ( byte )   0x6E ,   ( byte )   0x67 ,   ( byte )   0x2F ,   ( byte )   0x4F ,   ( byte )   0x62 ,   ( byte )   0x6A ,   ( byte )   0x65 ,   ( byte )   0x63 ,   ( byte )   0x74 ,   ( byte )   0x00 ,   ( byte )   0x21 ,   ( byte )   0x00 ,   ( byte )   0x02 ,   ( byte )   0x00 ,   ( byte )   0x03 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x1A ,   ( byte )   0x00 ,   ( byte )   0x04 ,   ( byte )   0x00 ,   ( byte )   0x05 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x06 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x02 ,   ( byte )   0x00 ,   ( byte )   0x07 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x09 ,   ( byte )   0x00 ,   ( byte )   0x0A ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x0B ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x2F ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x05 ,   ( byte )   0x2A ,   ( byte )   0xB7 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0xB1 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x02 ,   ( byte )   0x00 ,   ( byte )   0x0C ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x06 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x03 ,   ( byte )   0x00 ,   ( byte )   0x0D ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x0C ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x05 ,   ( byte )   0x00 ,   ( byte )   0x0E ,   ( byte )   0x00 ,   ( byte )   0x0F ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x01 ,   ( byte )   0x00 ,   ( byte )   0x10 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x00 ,   ( byte )   0x02 ,   ( byte )   0x00 ,   ( byte )   0x11 });
     }

    @ Test
     public   void  testMagicNumber ()   {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()   {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()   {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()   {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 20 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "X" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "D" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ConstantValue" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkDouble ( entry ,   11.000000 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithDoubleConstant;" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithDoubleConstant.java" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   9 ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithDoubleConstant" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()   {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()   {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()   {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()   {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithDoubleTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithDoubleTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithDoubleTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x06 ,   ( byte ) 0x40 ,   ( byte ) 0x26 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x78 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x44 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x3A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x2A ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0xB5 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x11   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 21 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   6 ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkDouble ( entry ,   11.000000 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkField ( entry ,   5 ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   21 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "x" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "D" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithDouble;" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithDouble.java" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   9 ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   7 ,   8 );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithDouble" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 5 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 6 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithLongTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithLongTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithLongTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x78 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x4A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x3A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x2A ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0xB5 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x11   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 21 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   6 ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkLong ( entry ,   13L );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkField ( entry ,   5 ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   21 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "x" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "J" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithLong;" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithLong.java" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   9 ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   7 ,   8 );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithLong" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 5 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 6 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/ModuleInfoTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/ModuleInfoTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ModuleInfoTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6D ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x2D ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x4D ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x31 ,   ( byte ) 0x31 ,   ( byte ) 0x2E ,   ( byte ) 0x30 ,   ( byte ) 0x2E ,   ( byte ) 0x35 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x6D ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x2D ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x7A ,   ( byte ) 0x79 ,   ( byte ) 0x2E ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x70 ,   ( byte ) 0x72 ,   ( byte ) 0x6F ,   ( byte ) 0x76 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2E ,   ( byte ) 0x62 ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x62 ,   ( byte ) 0x79 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x62 ,   ( byte ) 0x75 ,   ( byte ) 0x64 ,   ( byte ) 0x64 ,   ( byte ) 0x79 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x76 ,   ( byte ) 0x2F ,   ( byte ) 0x6D ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x6C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x7A ,   ( byte ) 0x79 ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x80 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x80 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 14 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkClass ( entry ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "module-info.java" );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Module" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkModule ( entry ,   11 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkModule ( entry ,   12 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "11.0.5" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkModule ( entry ,   13 );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkPackage ( entry ,   14 );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "module-info" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "lazy.constant.valueprovider" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java.base" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "net.bytebuddy" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "dev/morling/lazyconstant" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 32768 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 1 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithStringConstantTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithStringConstantTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithStringConstantTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x58 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x25 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x23 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x48 ,   ( byte ) 0x65 ,   ( byte ) 0x6C ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x2C ,   ( byte ) 0x20 ,   ( byte ) 0x57 ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x6C ,   ( byte ) 0x64 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x10   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 20 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "X" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ConstantValue" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkString ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithStringConstant;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithStringConstant.java" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithStringConstant" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Hello, World!" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/InterfaceWithAbstractMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/InterfaceWithAbstractMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   InterfaceWithAbstractMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x06 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x04 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 8 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkClass ( entry ,   7 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   8 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "InterfaceWithAbstractMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/InterfaceWithAbstractMethod" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1537 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 1 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithLongConstantTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithLongConstantTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithLongConstantTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x58 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x4A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x23 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x11   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 20 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "X" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "J" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ConstantValue" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkLong ( entry ,   13L );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithLongConstant;" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithLongConstant.java" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   9 ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithLongConstant" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassWithDefaultMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassWithDefaultMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ClassWithDefaultMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x1E ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x29 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x6D ,   ( byte ) 0x61 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x28 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x67 ,   ( byte ) 0x76 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2D ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x62 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x27 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x69 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0xBB ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x59 ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x4C ,   ( byte ) 0xBB ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x59 ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x4D ,   ( byte ) 0x2B ,   ( byte ) 0xB9 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0xB6 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x17   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 29 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   6 ,   24 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   25 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   24 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkInterfaceMethod ( entry ,   7 ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   27 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkClass ( entry ,   28 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/ClassWithDefaultMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "main" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "([Ljava/lang/String;)V" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "argv" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "[Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "a" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/InterfaceWithDefaultMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "b" );

        entry  =  classFile . getConstantPoolEntry ( 22 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 23 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ClassWithDefaultMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 24 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 25 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/ClassWithDefaultMethod" );

        entry  =  classFile . getConstantPoolEntry ( 26 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   29 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 27 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 28 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/InterfaceWithDefaultMethod" );

        entry  =  classFile . getConstantPoolEntry ( 29 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 6 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 1 ));
        assertThat ( classFile . getInterface ( 0 ),  equalTo ( 7 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/AbstractClassWithAbstractMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/AbstractClassWithAbstractMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   AbstractClassWithAbstractMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x32 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x24 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x30 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x41 ,   ( byte ) 0x62 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x04 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0E   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 18 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   16 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkClass ( entry ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/AbstractClassWithAbstractMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "AbstractClassWithAbstractMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   5 ,   6 );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/AbstractClassWithAbstractMethod" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/InterfaceWithAbstractMethod" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1057 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 1 ));
        assertThat ( classFile . getInterface ( 0 ),  equalTo ( 4 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithStringTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithStringTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithStringTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x78 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x48 ,   ( byte ) 0x65 ,   ( byte ) 0x6C ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x2C ,   ( byte ) 0x20 ,   ( byte ) 0x57 ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x6C ,   ( byte ) 0x64 ,   ( byte ) 0x21 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x2A ,   ( byte ) 0x12 ,   ( byte ) 0x02 ,   ( byte ) 0xB5 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x10   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 21 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   5 ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkString ( entry ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkField ( entry ,   4 ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkClass ( entry ,   21 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "x" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithString;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithString.java" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Hello, World!" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   6 ,   7 );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithString" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 4 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 5 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassWithImplementsTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassWithImplementsTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ClassWithImplementsTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x26 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x53 ,   ( byte ) 0x69 ,   ( byte ) 0x67 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0xCB ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x3C ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x3B ,   ( byte ) 0x3E ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x69 ,   ( byte ) 0x7A ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x3C ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x3E ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x3C ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x3E ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x6F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x73 ,   ( byte ) 0x65 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x24 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x49 ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x69 ,   ( byte ) 0x7A ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x2F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x41 ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x6F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x73 ,   ( byte ) 0x65 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x04 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x13   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 27 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   21 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   22 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkClass ( entry ,   23 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkClass ( entry ,   24 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   25 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkClass ( entry ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkClass ( entry ,   27 );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/ClassWithImplements;" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Signature" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/lang/Object;Ljava/lang/Comparable<Lca/bcit/comp2526/ClassWithImplements;>;Ljava/io/Serializable;Ljava/util/List<Ljava/lang/String;>;Ljava/lang/Iterable<Ljava/lang/String;>;Ljava/lang/AutoCloseable;" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ClassWithImplements.java" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   9 ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/ClassWithImplements" );

        entry  =  classFile . getConstantPoolEntry ( 22 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 23 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Comparable" );

        entry  =  classFile . getConstantPoolEntry ( 24 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/io/Serializable" );

        entry  =  classFile . getConstantPoolEntry ( 25 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/util/List" );

        entry  =  classFile . getConstantPoolEntry ( 26 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Iterable" );

        entry  =  classFile . getConstantPoolEntry ( 27 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/AutoCloseable" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 1057 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 5 ));
        assertThat ( classFile . getInterface ( 0 ),  equalTo ( 4 ));
        assertThat ( classFile . getInterface ( 1 ),  equalTo ( 5 ));
        assertThat ( classFile . getInterface ( 2 ),  equalTo ( 6 ));
        assertThat ( classFile . getInterface ( 3 ),  equalTo ( 7 ));
        assertThat ( classFile . getInterface ( 4 ),  equalTo ( 8 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassOverridesDefaultMethodTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/ClassOverridesDefaultMethodTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ClassOverridesDefaultMethodTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x1E ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2E ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x4F ,   ( byte ) 0x76 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x66 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x6D ,   ( byte ) 0x61 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x28 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x67 ,   ( byte ) 0x76 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2D ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x62 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x4F ,   ( byte ) 0x76 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x4F ,   ( byte ) 0x76 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x49 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x44 ,   ( byte ) 0x65 ,   ( byte ) 0x66 ,   ( byte ) 0x61 ,   ( byte ) 0x75 ,   ( byte ) 0x6C ,   ( byte ) 0x74 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x69 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0xBB ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x59 ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x4C ,   ( byte ) 0xBB ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x59 ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x4D ,   ( byte ) 0x2B ,   ( byte ) 0xB9 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0xB6 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x20 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x18   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 29 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   6 ,   25 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   26 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   25 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkInterfaceMethod ( entry ,   7 ,   27 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   27 );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   28 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkClass ( entry ,   29 );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/ClassOverridesDefaultMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "foo" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "main" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "([Ljava/lang/String;)V" );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "argv" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "[Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "a" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/InterfaceWithDefaultMethod;" );

        entry  =  classFile . getConstantPoolEntry ( 22 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "b" );

        entry  =  classFile . getConstantPoolEntry ( 23 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 24 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ClassOverridesDefaultMethod.java" );

        entry  =  classFile . getConstantPoolEntry ( 25 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 26 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/ClassOverridesDefaultMethod" );

        entry  =  classFile . getConstantPoolEntry ( 27 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   15 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 28 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 29 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/InterfaceWithDefaultMethod" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 6 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 1 ));
        assertThat ( classFile . getInterface ( 0 ),  equalTo ( 7 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/WithFloatConstantTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/WithFloatConstantTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   WithFloatConstantTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x58 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x46 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x04 ,   ( byte ) 0x41 ,   ( byte ) 0x31 ,   ( byte ) 0x99 ,   ( byte ) 0x9A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x24 ,   ( byte ) 0x4C ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x62 ,   ( byte ) 0x63 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6D ,   ( byte ) 0x70 ,   ( byte ) 0x32 ,   ( byte ) 0x35 ,   ( byte ) 0x32 ,   ( byte ) 0x36 ,   ( byte ) 0x2F ,   ( byte ) 0x57 ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x46 ,   ( byte ) 0x6C ,   ( byte ) 0x6F ,   ( byte ) 0x61 ,   ( byte ) 0x74 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x10   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 19 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkMethod ( entry ,   3 ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkClass ( entry ,   19 );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "X" );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "F" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ConstantValue" );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkFloat ( entry ,   11.100000f );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Lca/bcit/comp2526/WithFloatConstant;" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "WithFloatConstant.java" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ca/bcit/comp2526/WithFloatConstant" );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 3 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 0 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/classes/ValueProviderConstantDynamicTests.java

Assignment 3/src/test/ca/bcit/comp2526/classes/ValueProviderConstantDynamicTests.java

package  ca . bcit . comp2526 . classes ;

import  ca . bcit . comp2526 . ClassFile ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . ClassFileTest ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  ca . bcit . comp2526 . constantpool . ConstantPoolEntry ;
import  ca . bcit . comp2526 . constantpool . MethodHandleKind ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertNotNull ;
import   static  org . junit . jupiter . api . Assertions . assertNull ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ValueProviderConstantDynamicTests
     extends   ClassFileTest
{
     private   ClassFile  classFile ;

    @ BeforeAll
     public   void  createClassFile ()
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        classFile  =  createClassFile ( new   byte []   {   ( byte ) 0xCA ,   ( byte ) 0xFE ,   ( byte ) 0xBA ,   ( byte ) 0xBE ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x40 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x35 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x76 ,   ( byte ) 0x2F ,   ( byte ) 0x6D ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x6C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x7A ,   ( byte ) 0x79 ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x6F ,   ( byte ) 0x76 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x44 ,   ( byte ) 0x79 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x69 ,   ( byte ) 0x63 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x26 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x76 ,   ( byte ) 0x2F ,   ( byte ) 0x6D ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x6C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x7A ,   ( byte ) 0x79 ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x6F ,   ( byte ) 0x76 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x6F ,   ( byte ) 0x76 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x44 ,   ( byte ) 0x79 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x69 ,   ( byte ) 0x63 ,   ( byte ) 0x2E ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x3C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x69 ,   ( byte ) 0x74 ,   ( byte ) 0x3E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x69 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x4C ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x76 ,   ( byte ) 0x2F ,   ( byte ) 0x6D ,   ( byte ) 0x6F ,   ( byte ) 0x72 ,   ( byte ) 0x6C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x7A ,   ( byte ) 0x79 ,   ( byte ) 0x63 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x2F ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x6F ,   ( byte ) 0x76 ,   ( byte ) 0x69 ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x44 ,   ( byte ) 0x79 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x69 ,   ( byte ) 0x63 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x67 ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x28 ,   ( byte ) 0x29 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x64 ,   ( byte ) 0x6F ,   ( byte ) 0x47 ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x75 ,   ( byte ) 0x65 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x11 ,   ( byte ) 0x0F ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x23 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x6E ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x42 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x70 ,   ( byte ) 0x73 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x90 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x48 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x64 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x73 ,   ( byte ) 0x24 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x75 ,   ( byte ) 0x70 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x43 ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x73 ,   ( byte ) 0x73 ,   ( byte ) 0x3B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x6F ,   ( byte ) 0x6B ,   ( byte ) 0x65 ,   ( byte ) 0x2F ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x48 ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x64 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x3B ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x4F ,   ( byte ) 0x62 ,   ( byte ) 0x6A ,   ( byte ) 0x65 ,   ( byte ) 0x63 ,   ( byte ) 0x74 ,   ( byte ) 0x3B ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x00 ,   ( byte ) 0x17 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x00 ,   ( byte ) 0x18 ,   ( byte ) 0x0F ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x19 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x6E ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x1B ,   ( byte ) 0x00 ,   ( byte ) 0x1C ,   ( byte ) 0x11 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1D ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x54 ,   ( byte ) 0x48 ,   ( byte ) 0x45 ,   ( byte ) 0x5F ,   ( byte ) 0x56 ,   ( byte ) 0x41 ,   ( byte ) 0x4C ,   ( byte ) 0x55 ,   ( byte ) 0x45 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x1F ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x79 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x6D ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x67 ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x65 ,   ( byte ) 0x6E ,   ( byte ) 0x76 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x26 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x23 ,   ( byte ) 0x00 ,   ( byte ) 0x24 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x00 ,   ( byte ) 0x25 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x6D ,   ( byte ) 0x61 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x16 ,   ( byte ) 0x28 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x72 ,   ( byte ) 0x75 ,   ( byte ) 0x6E ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x2A ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x2B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x67 ,   ( byte ) 0x73 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x5B ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x74 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x2F ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x65 ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x3B ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x30 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x22 ,   ( byte ) 0x00 ,   ( byte ) 0x31 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x33 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x69 ,   ( byte ) 0x6F ,   ( byte ) 0x2F ,   ( byte ) 0x50 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x65 ,   ( byte ) 0x61 ,   ( byte ) 0x6D ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x35 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x70 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x74 ,   ( byte ) 0x6C ,   ( byte ) 0x6E ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x15 ,   ( byte ) 0x28 ,   ( byte ) 0x4C ,   ( byte ) 0x6A ,   ( byte ) 0x61 ,   ( byte ) 0x76 ,   ( byte ) 0x61 ,   ( byte ) 0x2F ,   ( byte ) 0x6C ,   ( byte ) 0x61 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x2F ,   ( byte ) 0x53 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x67 ,   ( byte ) 0x3B ,   ( byte ) 0x29 ,   ( byte ) 0x56 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x37 ,   ( byte ) 0x00 ,   ( byte ) 0x38 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x36 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x43 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x4C ,   ( byte ) 0x69 ,   ( byte ) 0x6E ,   ( byte ) 0x65 ,   ( byte ) 0x4E ,   ( byte ) 0x75 ,   ( byte ) 0x6D ,   ( byte ) 0x62 ,   ( byte ) 0x65 ,   ( byte ) 0x72 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x12 ,   ( byte ) 0x4C ,   ( byte ) 0x6F ,   ( byte ) 0x63 ,   ( byte ) 0x61 ,   ( byte ) 0x6C ,   ( byte ) 0x56 ,   ( byte ) 0x61 ,   ( byte ) 0x72 ,   ( byte ) 0x69 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x54 ,   ( byte ) 0x61 ,   ( byte ) 0x62 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x53 ,   ( byte ) 0x6F ,   ( byte ) 0x75 ,   ( byte ) 0x72 ,   ( byte ) 0x63 ,   ( byte ) 0x65 ,   ( byte ) 0x46 ,   ( byte ) 0x69 ,   ( byte ) 0x6C ,   ( byte ) 0x65 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x42 ,   ( byte ) 0x6F ,   ( byte ) 0x6F ,   ( byte ) 0x74 ,   ( byte ) 0x73 ,   ( byte ) 0x74 ,   ( byte ) 0x72 ,   ( byte ) 0x61 ,   ( byte ) 0x70 ,   ( byte ) 0x4D ,   ( byte ) 0x65 ,   ( byte ) 0x74 ,   ( byte ) 0x68 ,   ( byte ) 0x6F ,   ( byte ) 0x64 ,   ( byte ) 0x73 ,   ( byte ) 0x00 ,   ( byte ) 0x21 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x04 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x3B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x2A ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x3C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x3D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x05 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x0E ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x3B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x2D ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x12 ,   ( byte ) 0x1E ,   ( byte ) 0xB0 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x3C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x3D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x03 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x3B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x1E ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x12 ,   ( byte ) 0x20 ,   ( byte ) 0xB8 ,   ( byte ) 0x00 ,   ( byte ) 0x26 ,   ( byte ) 0xB0 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x3C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x06 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x27 ,   ( byte ) 0x00 ,   ( byte ) 0x28 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x3B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0xBB ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x59 ,   ( byte ) 0xB7 ,   ( byte ) 0x00 ,   ( byte ) 0x29 ,   ( byte ) 0xB6 ,   ( byte ) 0x00 ,   ( byte ) 0x2C ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x3C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0F ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x10 ,   ( byte ) 0x00 ,   ( byte ) 0x3D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x2D ,   ( byte ) 0x00 ,   ( byte ) 0x2E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x2A ,   ( byte ) 0x00 ,   ( byte ) 0x09 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x3B ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x39 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0xB2 ,   ( byte ) 0x00 ,   ( byte ) 0x32 ,   ( byte ) 0x2A ,   ( byte ) 0xB6 ,   ( byte ) 0x00 ,   ( byte ) 0x34 ,   ( byte ) 0xB6 ,   ( byte ) 0x00 ,   ( byte ) 0x3A ,   ( byte ) 0xB1 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x3C ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x13 ,   ( byte ) 0x00 ,   ( byte ) 0x0A ,   ( byte ) 0x00 ,   ( byte ) 0x14 ,   ( byte ) 0x00 ,   ( byte ) 0x3D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x0B ,   ( byte ) 0x00 ,   ( byte ) 0x0C ,   ( byte ) 0x00 ,   ( byte ) 0x0D ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x3E ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x02 ,   ( byte ) 0x00 ,   ( byte ) 0x07 ,   ( byte ) 0x00 ,   ( byte ) 0x3F ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x00 ,   ( byte ) 0x08 ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x1A ,   ( byte ) 0x00 ,   ( byte ) 0x01 ,   ( byte ) 0x00 ,   ( byte ) 0x13   });
     }

    @ Test
     public   void  testMagicNumber ()
     {
        assertThat ( classFile . getMagicNumber (),  equalTo ( 0xCAFEBABEL ));
     }

    @ Test
     public   void  testMinorNumber ()
     {
        assertThat ( classFile . getMinorVersion (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testMajorNumber ()
     {
        assertThat ( classFile . getMajorVersion (),  equalTo ( 55 ));
     }

    @ Test
     public   void  testConstantPool ()
     {
         ConstantPoolEntry  entry ;

        assertThat ( classFile . getConstantPoolCount (),  equalTo ( 63 ));

        entry  =  classFile . getConstantPoolEntry ( 0 );
        assertNull ( entry );

        entry  =  classFile . getConstantPoolEntry ( 1 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "dev/morling/lazyconstant/ValueProviderConstantDynamic" );

        entry  =  classFile . getConstantPoolEntry ( 2 );
        assertNotNull ( entry );
        checkClass ( entry ,   1 );

        entry  =  classFile . getConstantPoolEntry ( 3 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/Object" );

        entry  =  classFile . getConstantPoolEntry ( 4 );
        assertNotNull ( entry );
        checkClass ( entry ,   3 );

        entry  =  classFile . getConstantPoolEntry ( 5 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "dev/morling/lazyconstant/ValueProvider" );

        entry  =  classFile . getConstantPoolEntry ( 6 );
        assertNotNull ( entry );
        checkClass ( entry ,   5 );

        entry  =  classFile . getConstantPoolEntry ( 7 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "ValueProviderConstantDynamic.java" );

        entry  =  classFile . getConstantPoolEntry ( 8 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "<init>" );

        entry  =  classFile . getConstantPoolEntry ( 9 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()V" );

        entry  =  classFile . getConstantPoolEntry ( 10 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   8 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 11 );
        assertNotNull ( entry );
        checkMethod ( entry ,   4 ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 12 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "this" );

        entry  =  classFile . getConstantPoolEntry ( 13 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ldev/morling/lazyconstant/ValueProviderConstantDynamic;" );

        entry  =  classFile . getConstantPoolEntry ( 14 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "getValue" );

        entry  =  classFile . getConstantPoolEntry ( 15 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "()Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 16 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "doGetValue" );

        entry  =  classFile . getConstantPoolEntry ( 17 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   16 ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 18 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   17 );

        entry  =  classFile . getConstantPoolEntry ( 19 );
        assertNotNull ( entry );
        checkMethodHandle ( entry ,   MethodHandleKind . INVOKE_STATIC ,   18 );

        entry  =  classFile . getConstantPoolEntry ( 20 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/invoke/ConstantBootstraps" );

        entry  =  classFile . getConstantPoolEntry ( 21 );
        assertNotNull ( entry );
        checkClass ( entry ,   20 );

        entry  =  classFile . getConstantPoolEntry ( 22 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "invoke" );

        entry  =  classFile . getConstantPoolEntry ( 23 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object;" );

        entry  =  classFile . getConstantPoolEntry ( 24 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   22 ,   23 );

        entry  =  classFile . getConstantPoolEntry ( 25 );
        assertNotNull ( entry );
        checkMethod ( entry ,   21 ,   24 );

        entry  =  classFile . getConstantPoolEntry ( 26 );
        assertNotNull ( entry );
        checkMethodHandle ( entry ,   MethodHandleKind . INVOKE_STATIC ,   25 );

        entry  =  classFile . getConstantPoolEntry ( 27 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "name" );

        entry  =  classFile . getConstantPoolEntry ( 28 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 29 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   27 ,   28 );

        entry  =  classFile . getConstantPoolEntry ( 30 );
        assertNotNull ( entry );
        checkDynamic ( entry ,   0 ,   29 );

        entry  =  classFile . getConstantPoolEntry ( 31 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "THE_VALUE" );

        entry  =  classFile . getConstantPoolEntry ( 32 );
        assertNotNull ( entry );
        checkString ( entry ,   31 );

        entry  =  classFile . getConstantPoolEntry ( 33 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/lang/System" );

        entry  =  classFile . getConstantPoolEntry ( 34 );
        assertNotNull ( entry );
        checkClass ( entry ,   33 );

        entry  =  classFile . getConstantPoolEntry ( 35 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "getenv" );

        entry  =  classFile . getConstantPoolEntry ( 36 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/lang/String;)Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 37 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   35 ,   36 );

        entry  =  classFile . getConstantPoolEntry ( 38 );
        assertNotNull ( entry );
        checkMethod ( entry ,   34 ,   37 );

        entry  =  classFile . getConstantPoolEntry ( 39 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "main" );

        entry  =  classFile . getConstantPoolEntry ( 40 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "([Ljava/lang/String;)V" );

        entry  =  classFile . getConstantPoolEntry ( 41 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   10 );

        entry  =  classFile . getConstantPoolEntry ( 42 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "run" );

        entry  =  classFile . getConstantPoolEntry ( 43 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   42 ,   9 );

        entry  =  classFile . getConstantPoolEntry ( 44 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   43 );

        entry  =  classFile . getConstantPoolEntry ( 45 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "args" );

        entry  =  classFile . getConstantPoolEntry ( 46 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "[Ljava/lang/String;" );

        entry  =  classFile . getConstantPoolEntry ( 47 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "out" );

        entry  =  classFile . getConstantPoolEntry ( 48 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Ljava/io/PrintStream;" );

        entry  =  classFile . getConstantPoolEntry ( 49 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   47 ,   48 );

        entry  =  classFile . getConstantPoolEntry ( 50 );
        assertNotNull ( entry );
        checkField ( entry ,   34 ,   49 );

        entry  =  classFile . getConstantPoolEntry ( 51 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   14 ,   15 );

        entry  =  classFile . getConstantPoolEntry ( 52 );
        assertNotNull ( entry );
        checkMethod ( entry ,   2 ,   51 );

        entry  =  classFile . getConstantPoolEntry ( 53 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "java/io/PrintStream" );

        entry  =  classFile . getConstantPoolEntry ( 54 );
        assertNotNull ( entry );
        checkClass ( entry ,   53 );

        entry  =  classFile . getConstantPoolEntry ( 55 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "println" );

        entry  =  classFile . getConstantPoolEntry ( 56 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "(Ljava/lang/String;)V" );

        entry  =  classFile . getConstantPoolEntry ( 57 );
        assertNotNull ( entry );
        checkNameAndType ( entry ,   55 ,   56 );

        entry  =  classFile . getConstantPoolEntry ( 58 );
        assertNotNull ( entry );
        checkMethod ( entry ,   54 ,   57 );

        entry  =  classFile . getConstantPoolEntry ( 59 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "Code" );

        entry  =  classFile . getConstantPoolEntry ( 60 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LineNumberTable" );

        entry  =  classFile . getConstantPoolEntry ( 61 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "LocalVariableTable" );

        entry  =  classFile . getConstantPoolEntry ( 62 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "SourceFile" );

        entry  =  classFile . getConstantPoolEntry ( 63 );
        assertNotNull ( entry );
        checkUTF8 ( entry ,   "BootstrapMethods" );
     }

    @ Test
     public   void  testAccess ()
     {
        assertThat ( classFile . getAccessFlags (),  equalTo ( 33 ));
     }

    @ Test
     public   void  testThisClass ()
     {
        assertThat ( classFile . getThisClass (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testSuperClass ()
     {
        assertThat ( classFile . getSuperClass (),  equalTo ( 4 ));
     }

    @ Test
     public   void  testInterfaces ()
     {
        assertThat ( classFile . getInterfacesCount (),  equalTo ( 1 ));
        assertThat ( classFile . getInterface ( 0 ),  equalTo ( 6 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryInvokeDynamicTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryInvokeDynamicTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryInvokeDynamicTest
     extends   ConstantPoolEntryTest < ConstantPoolEntryInvokeDynamic >
{
    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 1 ));
     }

    @ Override
     protected   ConstantPoolEntryInvokeDynamic  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryInvokeDynamic  entry ;

        entry  =   new   ConstantPoolEntryInvokeDynamic ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00   });
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {   0x00 ,   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00 ,   0x01 ,   0x02   });
     }

    @ Test
     public   void  testBadNameAndTypeIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameAndTypeIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . INVOKE_DYNAMIC );
        testGetType ( entryB ,   ConstantPoolType . INVOKE_DYNAMIC );
     }

    @ Test
     public   void  testGetBootstrapMethodAttrIndex ()
     {
        assertThat ( entryA . getBootstrapMethodAttrIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getBootstrapMethodAttrIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testGetNameAndTypeIndex ()
     {
        assertThat ( entryA . getNameAndTypeIndex (),  equalTo ( 2 ));
        assertThat ( entryB . getNameAndTypeIndex (),  equalTo ( 1 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryPackageTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryPackageTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryPackageTest
     extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryPackage >
{
     public   ConstantPoolEntryPackageTest ()
     {
         super ( Short . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ));
     }

    @ Override
     protected   ConstantPoolEntryPackage  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryPackage  entry ;

        entry  =   new   ConstantPoolEntryPackage ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
     }

    @ Test
     public   void  testBadNameIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . PACKAGE );
        testGetType ( entryB ,   ConstantPoolType . PACKAGE );
     }

    @ Test
     public   void  testGetNameIndex ()
     {
        assertThat ( entryA . getNameIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getNameIndex (),  equalTo ( 2 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryUTF8Test.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryUTF8Test.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryUTF8Test
     extends   ConstantPoolEntryTest < ConstantPoolEntryUTF8 >
{
    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( "Hello" );
        entryB  =  createInstance ( "Hello, World!" );
     }

     private   ConstantPoolEntryUTF8  createInstance ( final   String  value )
         throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
         final   byte []  bytes ;
         final   ConstantPoolEntryUTF8  entry ;

        bytes  =   ByteUtils . stringToBytes ( value );
        entry  =  createInstance ( ByteUtils . unsignedShortToBytes ( bytes . length ),  bytes );

         return  entry ;
     }

    @ Override
     protected   ConstantPoolEntryUTF8  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException
     {
         final   ConstantPoolEntryUTF8  entry ;

        entry  =   new   ConstantPoolEntryUTF8 ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00   });
        testNotEnoughData ( 1 ,   0 ,   new   byte []   {   0x00 ,   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00 ,   0x02 ,   0x02   });
        testNotEnoughData ( 3 ,   2 ,   new   byte []   {   0x00 ,   0x03 ,   0x02 ,   0x01   });
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . UTF8 );
        testGetType ( entryB ,   ConstantPoolType . UTF8 );
     }

    @ Test
     public   void  getGetBytes ()
     {
        assertThat ( entryA . getBytes (),  equalTo ( "Hello" . getBytes ()));
        assertThat ( entryB . getBytes (),  equalTo ( "Hello, World!" . getBytes ()));
     }

    @ Test
     public   void  testGetString ()
     {
        assertThat ( entryA . getString (),  equalTo ( "Hello" ));
        assertThat ( entryB . getString (),  equalTo ( "Hello, World!" ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/MethodHandleKindTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/MethodHandleKindTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . InvalidReferenceKindException ;
import  org . hamcrest . CoreMatchers ;
import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . hamcrest . Matchers . equalTo ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

class   MethodHandleKindTest
{
    @ Test
     void  testGetType ()
     {
        assertThat ( MethodHandleKind . GET_FIELD . getType (),  equalTo (( short ) 1 ));
        assertThat ( MethodHandleKind . GET_STATIC . getType (),  equalTo (( short ) 2 ));
        assertThat ( MethodHandleKind . PUT_FIELD . getType (),  equalTo (( short ) 3 ));
        assertThat ( MethodHandleKind . PUT_STATIC . getType (),  equalTo (( short ) 4 ));
        assertThat ( MethodHandleKind . INVOKE_VIRTUAL . getType (),  equalTo (( short ) 5 ));
        assertThat ( MethodHandleKind . INVOKE_STATIC . getType (),  equalTo (( short ) 6 ));
        assertThat ( MethodHandleKind . INVOKE_SPECIAL . getType (),  equalTo (( short ) 7 ));
        assertThat ( MethodHandleKind . NEW_INVOKE_SPECIAL . getType (),  equalTo (( short ) 8 ));
        assertThat ( MethodHandleKind . INVOKE_INTERFACE . getType (),  equalTo (( short ) 9 ));
     }

    @ Test
     void  fromType ()
         throws   InvalidReferenceKindException
     {
        assertThat ( MethodHandleKind . fromType (( short ) 1 ),  equalTo ( MethodHandleKind . GET_FIELD ));
        assertThat ( MethodHandleKind . fromType (( short ) 2 ),  equalTo ( MethodHandleKind . GET_STATIC ));
        assertThat ( MethodHandleKind . fromType (( short ) 3 ),  equalTo ( MethodHandleKind . PUT_FIELD ));
        assertThat ( MethodHandleKind . fromType (( short ) 4 ),  equalTo ( MethodHandleKind . PUT_STATIC ));
        assertThat ( MethodHandleKind . fromType (( short ) 5 ),  equalTo ( MethodHandleKind . INVOKE_VIRTUAL ));
        assertThat ( MethodHandleKind . fromType (( short ) 6 ),  equalTo ( MethodHandleKind . INVOKE_STATIC ));
        assertThat ( MethodHandleKind . fromType (( short ) 7 ),  equalTo ( MethodHandleKind . INVOKE_SPECIAL ));
        assertThat ( MethodHandleKind . fromType (( short ) 8 ),  equalTo ( MethodHandleKind . NEW_INVOKE_SPECIAL ));
        assertThat ( MethodHandleKind . fromType (( short ) 9 ),  equalTo ( MethodHandleKind . INVOKE_INTERFACE ));
     }

    @ Test
     void  fromBadType ()
     {
        fromBadType (( short ) 0 );
        fromBadType (( short ) 10 );
        fromBadType (( short ) 1223 );
     }

     void  fromBadType ( final   short  type )
     {
         final   InvalidReferenceKindException  ex ;

        ex  =  assertThrows ( InvalidReferenceKindException . class ,   ()   ->   MethodHandleKind . fromType ( type ));
        assertThat ( ex . getMessage (),   CoreMatchers . equalTo ( String . format ( "referenceKind must be between 1 and 9, was: %d" ,  type )));
     }

    @ Test
     void  values ()
     {
         // NOTE that .values() is a method that is provided by the compiler.
         // DO NOT CREATE A "values" METHOD!
        assertThat ( MethodHandleKind . values (),  equalTo (
             new   MethodHandleKind []
             {
                 MethodHandleKind . GET_FIELD ,
                 MethodHandleKind . GET_STATIC ,
                 MethodHandleKind . PUT_FIELD ,
                 MethodHandleKind . PUT_STATIC ,
                 MethodHandleKind . INVOKE_VIRTUAL ,
                 MethodHandleKind . INVOKE_STATIC ,
                 MethodHandleKind . INVOKE_SPECIAL ,
                 MethodHandleKind . NEW_INVOKE_SPECIAL ,
                 MethodHandleKind . INVOKE_INTERFACE ,
             }));
     }

    @ Test
     void  valueOf ()
     {
         // NOTE that .valueOf() is a method that is provided by the compiler.
         // DO NOT CREATE A "valueOf" METHOD!
        assertThat ( MethodHandleKind . valueOf ( "GET_FIELD" ),  equalTo ( MethodHandleKind . GET_FIELD ));
        assertThat ( MethodHandleKind . valueOf ( "GET_STATIC" ),  equalTo ( MethodHandleKind . GET_STATIC ));
        assertThat ( MethodHandleKind . valueOf ( "PUT_FIELD" ),  equalTo ( MethodHandleKind . PUT_FIELD ));
        assertThat ( MethodHandleKind . valueOf ( "PUT_STATIC" ),  equalTo ( MethodHandleKind . PUT_STATIC ));
        assertThat ( MethodHandleKind . valueOf ( "INVOKE_VIRTUAL" ),  equalTo ( MethodHandleKind . INVOKE_VIRTUAL ));
        assertThat ( MethodHandleKind . valueOf ( "INVOKE_STATIC" ),  equalTo ( MethodHandleKind . INVOKE_STATIC ));
        assertThat ( MethodHandleKind . valueOf ( "INVOKE_SPECIAL" ),  equalTo ( MethodHandleKind . INVOKE_SPECIAL ));
        assertThat ( MethodHandleKind . valueOf ( "NEW_INVOKE_SPECIAL" ),  equalTo ( MethodHandleKind . NEW_INVOKE_SPECIAL ));
        assertThat ( MethodHandleKind . valueOf ( "INVOKE_INTERFACE" ),  equalTo ( MethodHandleKind . INVOKE_INTERFACE ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryFieldTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryFieldTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryFieldTest
     extends   ConstantPoolEntryTest < ConstantPoolEntryField >
{
    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 1 ));
     }

    @ Override
     protected   ConstantPoolEntryField  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryField  entry ;

        entry  =   new   ConstantPoolEntryField ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00   });
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {   0x00 ,   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00 ,   0x01 ,   0x02   });
     }

    @ Test
     public   void  testBadClassIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 ),   ByteUtils . unsignedShortToBytes ( 1 )));
        assertThat ( ex . getMessage (),  equalTo ( "classIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testBadNameAndTypeIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameAndTypeIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . FIELD );
        testGetType ( entryB ,   ConstantPoolType . FIELD );
     }

    @ Test
     public   void  testGetClassIndex ()
     {
        assertThat ( entryA . getClassIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getClassIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testGetNameAndTypeIndex ()
     {
        assertThat ( entryA . getNameAndTypeIndex (),  equalTo ( 2 ));
        assertThat ( entryB . getNameAndTypeIndex (),  equalTo ( 1 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryDynamicTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryDynamicTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryDynamicTest
     extends   ConstantPoolEntryTest < ConstantPoolEntryDynamic >
{
    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 1 ));
     }

    @ Override
     protected   ConstantPoolEntryDynamic  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryDynamic  entry ;

        entry  =   new   ConstantPoolEntryDynamic ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00   });
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {   0x00 ,   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00 ,   0x01 ,   0x02   });
     }

    @ Test
     public   void  testBadNameAndTypeIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameAndTypeIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . DYNAMIC );
        testGetType ( entryB ,   ConstantPoolType . DYNAMIC );
     }

    @ Test
     public   void  testGetBootstrapMethodAttrIndex ()
     {
        assertThat ( entryA . getBootstrapMethodAttrIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getBootstrapMethodAttrIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testGetNameAndTypeIndex ()
     {
        assertThat ( entryA . getNameAndTypeIndex (),  equalTo ( 2 ));
        assertThat ( entryB . getNameAndTypeIndex (),  equalTo ( 1 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryStringTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryStringTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryStringTest
     extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryString >
{
     public   ConstantPoolEntryStringTest ()
     {
         super ( Short . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ));
     }

    @ Override
     protected   ConstantPoolEntryString  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryString  entry ;

        entry  =   new   ConstantPoolEntryString ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
     }

    @ Test
     public   void  testBadStringIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "stringIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . STRING );
        testGetType ( entryB ,   ConstantPoolType . STRING );
     }

    @ Test
     public   void  testGetStringIndex ()
     {
        assertThat ( entryA . getStringIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getStringIndex (),  equalTo ( 2 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryDoubleTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryDoubleTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryDoubleTest
         extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryDouble >
{
     public   ConstantPoolEntryDoubleTest ()
     {
         super ( Double . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException
     {
        entryA  =  createInstance ( ByteUtils . doubleToBytes ( Double . MAX_VALUE ));
        entryB  =  createInstance ( ByteUtils . doubleToBytes ( Double . MIN_VALUE ));
     }

    @ Override
     protected   ConstantPoolEntryDouble  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException
     {
         final   ConstantPoolEntryDouble  entry ;

        entry  =   new   ConstantPoolEntryDouble ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00   });
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   2 );
        testGetNumberOfSlots ( entryB ,   2 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . DOUBLE );
        testGetType ( entryB ,   ConstantPoolType . DOUBLE );
     }

    @ Test
     public   void  testGetValue ()
     {
        assertThat ( entryA . getValue (),  equalTo ( Double . MAX_VALUE ));
        assertThat ( entryB . getValue (),  equalTo ( Double . MIN_VALUE ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryIntegerTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryIntegerTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryIntegerTest
         extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryInteger >
{
     public   ConstantPoolEntryIntegerTest ()
     {
         super ( Integer . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException
     {
        entryA  =  createInstance ( ByteUtils . intToBytes ( Integer . MAX_VALUE ));
        entryB  =  createInstance ( ByteUtils . intToBytes ( Integer . MIN_VALUE ));
     }

    @ Override
     protected   ConstantPoolEntryInteger  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException
     {
         final   ConstantPoolEntryInteger  entry ;

        entry  =   new   ConstantPoolEntryInteger ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00   });
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . INTEGER );
        testGetType ( entryB ,   ConstantPoolType . INTEGER );
     }

    @ Test
     public   void  testGetValue ()
     {
        assertThat ( entryA . getValue (),  equalTo ( Integer . MAX_VALUE ));
        assertThat ( entryB . getValue (),  equalTo ( Integer . MIN_VALUE ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryModuleTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryModuleTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryModuleTest
     extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryModule >
{
     public   ConstantPoolEntryModuleTest ()
     {
         super ( Short . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ));
     }

    @ Override
     protected   ConstantPoolEntryModule  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryModule  entry ;

        entry  =   new   ConstantPoolEntryModule ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
     }

    @ Test
     public   void  testBadNameIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . MODULE );
        testGetType ( entryB ,   ConstantPoolType . MODULE );
     }

    @ Test
     public   void  testGetDescriptorIndex ()
     {
        assertThat ( entryA . getNameIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getNameIndex (),  equalTo ( 2 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryMethodTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryMethodTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryMethodTest
     extends   ConstantPoolEntryTest < ConstantPoolEntryMethod >
{
    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 1 ));
     }

    @ Override
     protected   ConstantPoolEntryMethod  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryMethod  entry ;

        entry  =   new   ConstantPoolEntryMethod ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00   });
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {   0x00 ,   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00 ,   0x01 ,   0x02   });
     }

    @ Test
     public   void  testBadClassIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 ),   ByteUtils . unsignedShortToBytes ( 1 )));
        assertThat ( ex . getMessage (),  equalTo ( "classIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testBadNameAndTypeIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameAndTypeIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . METHOD );
        testGetType ( entryB ,   ConstantPoolType . METHOD );
     }

    @ Test
     public   void  testGetClassIndex ()
     {
        assertThat ( entryA . getClassIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getClassIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testGetNameAndTypeIndex ()
     {
        assertThat ( entryA . getNameAndTypeIndex (),  equalTo ( 2 ));
        assertThat ( entryB . getNameAndTypeIndex (),  equalTo ( 1 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryNameAndTypeTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryNameAndTypeTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryNameAndTypeTest
     extends   ConstantPoolEntryTest < ConstantPoolEntryNameAndType >
{
    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 1 ));
     }

    @ Override
     protected   ConstantPoolEntryNameAndType  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryNameAndType  entry ;

        entry  =   new   ConstantPoolEntryNameAndType ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00   });
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {   0x00 ,   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00 ,   0x01 ,   0x02   });
     }

    @ Test
     public   void  testBadClassIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 ),   ByteUtils . unsignedShortToBytes ( 1 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testBadDescriptorIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "descriptorIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . NAME_AND_TYPE );
        testGetType ( entryB ,   ConstantPoolType . NAME_AND_TYPE );
     }

    @ Test
     public   void  testGetNameIndex ()
     {
        assertThat ( entryA . getNameIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getNameIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testGetDescriptorIndex ()
     {
        assertThat ( entryA . getDescriptorIndex (),  equalTo ( 2 ));
        assertThat ( entryB . getDescriptorIndex (),  equalTo ( 1 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryInterfaceMethodTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryInterfaceMethodTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryInterfaceMethodTest
     extends   ConstantPoolEntryTest < ConstantPoolEntryInterfaceMethod >
{
    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ),   ByteUtils . unsignedShortToBytes ( 1 ));
     }

    @ Override
     protected   ConstantPoolEntryInterfaceMethod  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryInterfaceMethod  entry ;

        entry  =   new   ConstantPoolEntryInterfaceMethod ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00   });
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {   0x00 ,   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x00 ,   0x01 ,   0x02   });
     }

    @ Test
     public   void  testBadClassIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 ),   ByteUtils . unsignedShortToBytes ( 1 )));
        assertThat ( ex . getMessage (),  equalTo ( "classIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testBadNameAndTypeIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameAndTypeIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . INTERFACE_METHOD );
        testGetType ( entryB ,   ConstantPoolType . INTERFACE_METHOD );
     }

    @ Test
     public   void  testGetClassIndex ()
     {
        assertThat ( entryA . getClassIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getClassIndex (),  equalTo ( 2 ));
     }

    @ Test
     public   void  testGetNameAndTypeIndex ()
     {
        assertThat ( entryA . getNameAndTypeIndex (),  equalTo ( 2 ));
        assertThat ( entryB . getNameAndTypeIndex (),  equalTo ( 1 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryMethodHandleTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryMethodHandleTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . * ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryMethodHandleTest
     extends   ConstantPoolEntryTest < ConstantPoolEntryMethodHandle >
{
     private   ConstantPoolEntryMethodHandle  entryC ;
     private   ConstantPoolEntryMethodHandle  entryD ;
     private   ConstantPoolEntryMethodHandle  entryE ;
     private   ConstantPoolEntryMethodHandle  entryF ;
     private   ConstantPoolEntryMethodHandle  entryG ;
     private   ConstantPoolEntryMethodHandle  entryH ;
     private   ConstantPoolEntryMethodHandle  entryI ;

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . GET_FIELD . getType ()),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryB  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . GET_STATIC . getType ()),   ByteUtils . unsignedShortToBytes ( 3 ));
        entryC  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . PUT_FIELD . getType ()),   ByteUtils . unsignedShortToBytes ( 3 ));
        entryD  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . PUT_STATIC . getType ()),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryE  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . INVOKE_VIRTUAL . getType ()),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryF  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . INVOKE_STATIC . getType ()),   ByteUtils . unsignedShortToBytes ( 3 ));
        entryG  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . INVOKE_SPECIAL . getType ()),   ByteUtils . unsignedShortToBytes ( 2 ));
        entryH  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . NEW_INVOKE_SPECIAL . getType ()),   ByteUtils . unsignedShortToBytes ( 3 ));
        entryI  =  createInstance ( ByteUtils . unsignedByteToBytes ( MethodHandleKind . INVOKE_INTERFACE . getType ()),   ByteUtils . unsignedShortToBytes ( 3 ));
     }

    @ Override
     protected   ConstantPoolEntryMethodHandle  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidReferenceKindException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryMethodHandle  entry ;

        entry  =   new   ConstantPoolEntryMethodHandle ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( 1 ,   0 ,   new   byte []   {});
        testNotEnoughData ( 2 ,   0 ,   new   byte []   {   0x01   });
        testNotEnoughData ( 2 ,   1 ,   new   byte []   {   0x01 ,   0x01   });
     }

    @ Test
     public   void  testBadReferenceKind ()
     {
         final   InvalidReferenceKindException  ex ;

        ex  =  assertThrows ( InvalidReferenceKindException . class ,   ()   ->  createInstance ( new   byte []   {   0x00   }));
        assertThat ( ex . getMessage (),  equalTo ( "referenceKind must be between 1 and 9, was: 0" ));
        assertThat ( ex . getValue (),  equalTo (( short ) 0 ));
     }

    @ Test
     public   void  testBadNameAndTypeIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedByteToBytes ( 1 ),   ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "referenceIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
        testGetNumberOfSlots ( entryC ,   1 );
        testGetNumberOfSlots ( entryD ,   1 );
        testGetNumberOfSlots ( entryE ,   1 );
        testGetNumberOfSlots ( entryF ,   1 );
        testGetNumberOfSlots ( entryG ,   1 );
        testGetNumberOfSlots ( entryH ,   1 );
        testGetNumberOfSlots ( entryI ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryB ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryC ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryD ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryE ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryF ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryG ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryH ,   ConstantPoolType . METHOD_HANDLE );
        testGetType ( entryI ,   ConstantPoolType . METHOD_HANDLE );
     }

    @ Test
     public   void  testGetReferenceKind ()
     {
        assertThat ( entryA . getReferenceKind (),  equalTo ( MethodHandleKind . GET_FIELD ));
        assertThat ( entryB . getReferenceKind (),  equalTo ( MethodHandleKind . GET_STATIC ));
        assertThat ( entryC . getReferenceKind (),  equalTo ( MethodHandleKind . PUT_FIELD ));
        assertThat ( entryD . getReferenceKind (),  equalTo ( MethodHandleKind . PUT_STATIC ));
        assertThat ( entryE . getReferenceKind (),  equalTo ( MethodHandleKind . INVOKE_VIRTUAL ));
        assertThat ( entryF . getReferenceKind (),  equalTo ( MethodHandleKind . INVOKE_STATIC ));
        assertThat ( entryG . getReferenceKind (),  equalTo ( MethodHandleKind . INVOKE_SPECIAL ));
        assertThat ( entryH . getReferenceKind (),  equalTo ( MethodHandleKind . NEW_INVOKE_SPECIAL ));
        assertThat ( entryI . getReferenceKind (),  equalTo ( MethodHandleKind . INVOKE_INTERFACE ));
     }

    @ Test
     public   void  testGetReferenceIndex ()
     {
        assertThat ( entryA . getReferenceIndex (),  equalTo ( 2 ));
        assertThat ( entryB . getReferenceIndex (),  equalTo ( 3 ));
        assertThat ( entryC . getReferenceIndex (),  equalTo ( 3 ));
        assertThat ( entryD . getReferenceIndex (),  equalTo ( 2 ));
        assertThat ( entryE . getReferenceIndex (),  equalTo ( 2 ));
        assertThat ( entryF . getReferenceIndex (),  equalTo ( 3 ));
        assertThat ( entryG . getReferenceIndex (),  equalTo ( 2 ));
        assertThat ( entryH . getReferenceIndex (),  equalTo ( 3 ));
        assertThat ( entryI . getReferenceIndex (),  equalTo ( 3 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolTypeTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolTypeTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . InvalidConstantPoolTagException ;
import  org . hamcrest . CoreMatchers ;
import  org . junit . jupiter . api . Test ;

import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . hamcrest . Matchers . equalTo ;
import   static  org . junit . jupiter . api . Assertions . * ;

class   ConstantPoolTypeTest
{
    @ Test
     void  getTag ()
     {
        assertThat ( ConstantPoolType . UTF8 . getTag (),  equalTo (( short ) 1 ));
        assertThat ( ConstantPoolType . INTEGER . getTag (),  equalTo (( short ) 3 ));
        assertThat ( ConstantPoolType . FLOAT . getTag (),  equalTo (( short ) 4 ));
        assertThat ( ConstantPoolType . LONG . getTag (),  equalTo (( short ) 5 ));
        assertThat ( ConstantPoolType . DOUBLE . getTag (),  equalTo (( short ) 6 ));
        assertThat ( ConstantPoolType . CLASS . getTag (),  equalTo (( short ) 7 ));
        assertThat ( ConstantPoolType . STRING . getTag (),  equalTo (( short ) 8 ));
        assertThat ( ConstantPoolType . FIELD . getTag (),  equalTo (( short ) 9 ));
        assertThat ( ConstantPoolType . METHOD . getTag (),  equalTo (( short ) 10 ));
        assertThat ( ConstantPoolType . INTERFACE_METHOD . getTag (),  equalTo (( short ) 11 ));
        assertThat ( ConstantPoolType . NAME_AND_TYPE . getTag (),  equalTo (( short ) 12 ));
        assertThat ( ConstantPoolType . METHOD_HANDLE . getTag (),  equalTo (( short ) 15 ));
        assertThat ( ConstantPoolType . METHOD_TYPE . getTag (),  equalTo (( short ) 16 ));
        assertThat ( ConstantPoolType . DYNAMIC . getTag (),  equalTo (( short ) 17 ));
        assertThat ( ConstantPoolType . INVOKE_DYNAMIC . getTag (),  equalTo (( short ) 18 ));
        assertThat ( ConstantPoolType . MODULE . getTag (),  equalTo (( short ) 19 ));
        assertThat ( ConstantPoolType . PACKAGE . getTag (),  equalTo (( short ) 20 ));
     }

    @ Test
     void  fromTag ()
         throws   InvalidConstantPoolTagException
     {
        assertThat ( ConstantPoolType . fromTag (( short ) 1 ),  equalTo ( ConstantPoolType . UTF8 ));
        assertThat ( ConstantPoolType . fromTag (( short ) 3 ),  equalTo ( ConstantPoolType . INTEGER ));
        assertThat ( ConstantPoolType . fromTag (( short ) 4 ),  equalTo ( ConstantPoolType . FLOAT ));
        assertThat ( ConstantPoolType . fromTag (( short ) 5 ),  equalTo ( ConstantPoolType . LONG ));
        assertThat ( ConstantPoolType . fromTag (( short ) 6 ),  equalTo ( ConstantPoolType . DOUBLE ));
        assertThat ( ConstantPoolType . fromTag (( short ) 7 ),  equalTo ( ConstantPoolType . CLASS ));
        assertThat ( ConstantPoolType . fromTag (( short ) 8 ),  equalTo ( ConstantPoolType . STRING ));
        assertThat ( ConstantPoolType . fromTag (( short ) 9 ),  equalTo ( ConstantPoolType . FIELD ));
        assertThat ( ConstantPoolType . fromTag (( short ) 10 ),  equalTo ( ConstantPoolType . METHOD ));
        assertThat ( ConstantPoolType . fromTag (( short ) 11 ),  equalTo ( ConstantPoolType . INTERFACE_METHOD ));
        assertThat ( ConstantPoolType . fromTag (( short ) 12 ),  equalTo ( ConstantPoolType . NAME_AND_TYPE ));
        assertThat ( ConstantPoolType . fromTag (( short ) 15 ),  equalTo ( ConstantPoolType . METHOD_HANDLE ));
        assertThat ( ConstantPoolType . fromTag (( short ) 16 ),  equalTo ( ConstantPoolType . METHOD_TYPE ));
        assertThat ( ConstantPoolType . fromTag (( short ) 17 ),  equalTo ( ConstantPoolType . DYNAMIC ));
        assertThat ( ConstantPoolType . fromTag (( short ) 18 ),  equalTo ( ConstantPoolType . INVOKE_DYNAMIC ));
        assertThat ( ConstantPoolType . fromTag (( short ) 19 ),  equalTo ( ConstantPoolType . MODULE ));
        assertThat ( ConstantPoolType . fromTag (( short ) 20 ),  equalTo ( ConstantPoolType . PACKAGE ));
     }

    @ Test
     void  fromBadTag ()
     {
        fromBadTag (( short ) 0 );
        fromBadTag (( short ) 2 );
        fromBadTag (( short ) 21 );
        fromBadTag (( short ) 23 );
        fromBadTag (( short ) 742 );
     }

     void  fromBadTag ( final   short  tag )
     {
         final   InvalidConstantPoolTagException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolTagException . class ,   ()   ->   ConstantPoolType . fromTag ( tag ));
        assertThat ( ex . getMessage (),   CoreMatchers . equalTo ( String . format ( "tag must be one of 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, was: %d" ,  tag )));
     }

    @ Test
     void  values ()
     {
         // NOTE that .values() is a method that is provided by the compiler.
         // DO NOT CREATE A "values" METHOD!
        assertThat ( ConstantPoolType . values (),  equalTo (
             new   ConstantPoolType []
             {
                 ConstantPoolType . UTF8 ,
                 ConstantPoolType . INTEGER ,
                 ConstantPoolType . FLOAT ,
                 ConstantPoolType . LONG ,
                 ConstantPoolType . DOUBLE ,
                 ConstantPoolType . CLASS ,
                 ConstantPoolType . STRING ,
                 ConstantPoolType . FIELD ,
                 ConstantPoolType . METHOD ,
                 ConstantPoolType . INTERFACE_METHOD ,
                 ConstantPoolType . NAME_AND_TYPE ,
                 ConstantPoolType . METHOD_HANDLE ,
                 ConstantPoolType . METHOD_TYPE ,
                 ConstantPoolType . DYNAMIC ,
                 ConstantPoolType . INVOKE_DYNAMIC ,
                 ConstantPoolType . MODULE ,
                 ConstantPoolType . PACKAGE ,
         }));
     }

    @ Test
     void  valueOf ()
     {
         // NOTE that .valueOf() is a method that is provided by the compiler.
         // DO NOT CREATE A "valueOf" METHOD!
        assertThat ( ConstantPoolType . valueOf ( "UTF8" ),  equalTo ( ConstantPoolType . UTF8 ));
        assertThat ( ConstantPoolType . valueOf ( "INTEGER" ),  equalTo ( ConstantPoolType . INTEGER ));
        assertThat ( ConstantPoolType . valueOf ( "FLOAT" ),  equalTo ( ConstantPoolType . FLOAT ));
        assertThat ( ConstantPoolType . valueOf ( "LONG" ),  equalTo ( ConstantPoolType . LONG ));
        assertThat ( ConstantPoolType . valueOf ( "DOUBLE" ),  equalTo ( ConstantPoolType . DOUBLE ));
        assertThat ( ConstantPoolType . valueOf ( "CLASS" ),  equalTo ( ConstantPoolType . CLASS ));
        assertThat ( ConstantPoolType . valueOf ( "STRING" ),  equalTo ( ConstantPoolType . STRING ));
        assertThat ( ConstantPoolType . valueOf ( "FIELD" ),  equalTo ( ConstantPoolType . FIELD ));
        assertThat ( ConstantPoolType . valueOf ( "METHOD" ),  equalTo ( ConstantPoolType . METHOD ));
        assertThat ( ConstantPoolType . valueOf ( "INTERFACE_METHOD" ),  equalTo ( ConstantPoolType . INTERFACE_METHOD ));
        assertThat ( ConstantPoolType . valueOf ( "NAME_AND_TYPE" ),  equalTo ( ConstantPoolType . NAME_AND_TYPE ));
        assertThat ( ConstantPoolType . valueOf ( "METHOD_HANDLE" ),  equalTo ( ConstantPoolType . METHOD_HANDLE ));
        assertThat ( ConstantPoolType . valueOf ( "METHOD_TYPE" ),  equalTo ( ConstantPoolType . METHOD_TYPE ));
        assertThat ( ConstantPoolType . valueOf ( "DYNAMIC" ),  equalTo ( ConstantPoolType . DYNAMIC ));
        assertThat ( ConstantPoolType . valueOf ( "INVOKE_DYNAMIC" ),  equalTo ( ConstantPoolType . INVOKE_DYNAMIC ));
        assertThat ( ConstantPoolType . valueOf ( "MODULE" ),  equalTo ( ConstantPoolType . MODULE ));
        assertThat ( ConstantPoolType . valueOf ( "PACKAGE" ),  equalTo ( ConstantPoolType . PACKAGE ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryFloatTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryFloatTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryFloatTest
         extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryFloat >
{
     public   ConstantPoolEntryFloatTest ()
     {
         super ( Float . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException
     {
        entryA  =  createInstance ( ByteUtils . floatToBytes ( Float . MAX_VALUE ));
        entryB  =  createInstance ( ByteUtils . floatToBytes ( Float . MIN_VALUE ));
     }

    @ Override
     protected   ConstantPoolEntryFloat  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException
     {
         final   ConstantPoolEntryFloat  entry ;

        entry  =   new   ConstantPoolEntryFloat ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00   });
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . FLOAT );
        testGetType ( entryB ,   ConstantPoolType . FLOAT );
     }

    @ Test
     public   void  testGetValue ()
     {
        assertThat ( entryA . getValue (),  equalTo ( Float . MAX_VALUE ));
        assertThat ( entryB . getValue (),  equalTo ( Float . MIN_VALUE ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;

import  java . io . ByteArrayOutputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

public   abstract   class   ConstantPoolEntryTest < extends   ConstantPoolEntry >
{
     protected  T entryA ;
     protected  T entryB ;

     protected   abstract  T createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException ;

     protected   final  T createInstance ( final   byte []   ...  byteCollection )
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
         try ( final   ByteArrayOutputStream  stream  =   new   ByteArrayOutputStream ())
         {
             final   byte []  bytes ;
             final  T entry ;

             for ( final   byte []  array  :  byteCollection )
             {
                stream . writeBytes ( array );
             }

            bytes  =  stream . toByteArray ();
            entry  =  createInstance ( bytes );

             return  entry ;
         }
     }

     protected   final   void  testGetNumberOfSlots ( final   ConstantPoolEntry  entry ,
                                               final   int                expected )
     {
        assertThat ( entry . getNumberOfSlots (),  equalTo ( expected ));
     }

     protected   final   void  testGetType ( final   ConstantPoolEntry  entry ,
                                      final   ConstantPoolType  expected )
     {
        assertThat ( entry . getType (),  equalTo ( expected ));
     }

     protected   final   void  testNotEnoughData ( final   int     expectedSize ,
                                            final   int     actualSize ,
                                            final   byte []  bytes )
     {
         final   NotEnoughDataException  ex ;

        ex  =  assertThrows ( NotEnoughDataException . class ,   ()   ->  createInstance ( bytes ));
        assertThat ( ex . getMessage (),  equalTo ( String . format ( "Require %d bytes to be available, have: %d" ,  expectedSize ,  actualSize )));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryClassTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryClassTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryClassTest
     extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryClass >
{
     public   ConstantPoolEntryClassTest ()
     {
         super ( Short . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ));
     }

    @ Override
     protected   ConstantPoolEntryClass  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryClass  entry ;

        entry  =   new   ConstantPoolEntryClass ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
     }

    @ Test
     public   void  testBadNameIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "nameIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . CLASS );
        testGetType ( entryB ,   ConstantPoolType . CLASS );
     }

    @ Test
     public   void  testGetNameIndex ()
     {
        assertThat ( entryA . getNameIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getNameIndex (),  equalTo ( 2 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryLongTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryLongTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryLongTest
         extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryLong >
{
     public   ConstantPoolEntryLongTest ()
     {
         super ( Long . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException
     {
        entryA  =  createInstance ( ByteUtils . longToBytes ( Long . MAX_VALUE ));
        entryB  =  createInstance ( ByteUtils . longToBytes ( Long . MIN_VALUE ));
     }

    @ Override
     protected   ConstantPoolEntryLong  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException
     {
         final   ConstantPoolEntryLong  entry ;

        entry  =   new   ConstantPoolEntryLong ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00   });
        testNotEnoughData ( new   byte []   {   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00 ,   0x00   });
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   2 );
        testGetNumberOfSlots ( entryB ,   2 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . LONG );
        testGetType ( entryB ,   ConstantPoolType . LONG );
     }

    @ Test
     public   void  testGetValue ()
     {
        assertThat ( entryA . getValue (),  equalTo ( Long . MAX_VALUE ));
        assertThat ( entryB . getValue (),  equalTo ( Long . MIN_VALUE ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryMethodTypeTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryMethodTypeTest.java

package  ca . bcit . comp2526 . constantpool ;

import  ca . bcit . comp2526 . ByteUtils ;
import  ca . bcit . comp2526 . ClassFileException ;
import  ca . bcit . comp2526 . InvalidConstantPoolIndexException ;
import  ca . bcit . comp2526 . NotEnoughDataException ;
import  org . junit . jupiter . api . BeforeAll ;
import  org . junit . jupiter . api . Test ;
import  org . junit . jupiter . api . TestInstance ;

import  java . io . ByteArrayInputStream ;
import  java . io . DataInputStream ;
import  java . io . IOException ;

import   static  org . hamcrest . CoreMatchers . equalTo ;
import   static  org . hamcrest . MatcherAssert . assertThat ;
import   static  org . junit . jupiter . api . Assertions . assertThrows ;

@ TestInstance ( TestInstance . Lifecycle . PER_CLASS )
public   class   ConstantPoolEntryMethodTypeTest
     extends   ConstantPoolEntryUnaryTest < ConstantPoolEntryMethodType >
{
     public   ConstantPoolEntryMethodTypeTest ()
     {
         super ( Short . BYTES );
     }

    @ BeforeAll
     public   void  createInstances ()
             throws   IOException ,
             NotEnoughDataException ,
             ClassFileException
     {
        entryA  =  createInstance ( ByteUtils . unsignedShortToBytes ( 1 ));
        entryB  =  createInstance ( ByteUtils . unsignedShortToBytes ( 2 ));
     }

    @ Override
     protected   ConstantPoolEntryMethodType  createInstance ( final   byte []  bytes )
             throws   IOException ,
             NotEnoughDataException ,
             InvalidConstantPoolIndexException
     {
         final   ConstantPoolEntryMethodType  entry ;

        entry  =   new   ConstantPoolEntryMethodType ( new   DataInputStream ( new   ByteArrayInputStream ( bytes )));

         return  entry ;
     }

    @ Test
     public   void  testNotEnoughData ()
     {
        testNotEnoughData ( new   byte []   {});
        testNotEnoughData ( new   byte []   {   0x00   });
     }

    @ Test
     public   void  testBadNameIndex ()
     {
         final   InvalidConstantPoolIndexException  ex ;

        ex  =  assertThrows ( InvalidConstantPoolIndexException . class ,   ()   ->  createInstance ( ByteUtils . unsignedShortToBytes ( 0 )));
        assertThat ( ex . getMessage (),  equalTo ( "descriptorIndex must be > 0, was: 0" ));
        assertThat ( ex . getIndex (),  equalTo ( 0 ));
     }

    @ Test
     public   void  testGetNumberOfSlots ()
     {
        testGetNumberOfSlots ( entryA ,   1 );
        testGetNumberOfSlots ( entryB ,   1 );
     }

    @ Test
     public   void  testGetType ()
     {
        testGetType ( entryA ,   ConstantPoolType . METHOD_TYPE );
        testGetType ( entryB ,   ConstantPoolType . METHOD_TYPE );
     }

    @ Test
     public   void  testGetDescriptorIndex ()
     {
        assertThat ( entryA . getDescriptorIndex (),  equalTo ( 1 ));
        assertThat ( entryB . getDescriptorIndex (),  equalTo ( 2 ));
     }
}

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryUnaryTest.java

Assignment 3/src/test/ca/bcit/comp2526/constantpool/ConstantPoolEntryUnaryTest.java

package  ca . bcit . comp2526 . constantpool ;

public   abstract   class   ConstantPoolEntryUnaryTest < extends   ConstantPoolEntry >
     extends   ConstantPoolEntryTest < T >
{
     private   final   int  expectedSize ;

     protected   ConstantPoolEntryUnaryTest ( final   int  expected )
     {
        expectedSize  =  expected ;
     }

     protected   final   void  testNotEnoughData ( final   byte []  bytes )
     {
        testNotEnoughData ( expectedSize ,  bytes );
     }

     protected   final   void  testNotEnoughData ( final   int     expectedSize ,
                                            final   byte []  bytes )
     {
        testNotEnoughData ( expectedSize ,  bytes . length ,  bytes );
     }
}

Assignment 3/src/main/ca/bcit/comp2526/constantpool/.DS_Store

__MACOSX/Assignment 3/src/main/ca/bcit/comp2526/constantpool/._.DS_Store

Classes.zip

AbstractClassWithAbstractMethod.java

AbstractClassWithAbstractMethod.java

package  ca . bcit . comp2526 ;

public   abstract   class   AbstractClassWithAbstractMethod
     implements   InterfaceWithAbstractMethod
{
    @ Override
     public   abstract   void  foo ();
}

AbstractClassWithFinalMethod.java

AbstractClassWithFinalMethod.java

package  ca . bcit . comp2526 ;

public   abstract   class   AbstractClassWithFinalMethod
     implements   InterfaceWithAbstractMethod
{
     public   final   void  foo ()
     {
     }
}

AbstractClassWithMethod.java

AbstractClassWithMethod.java

package  ca . bcit . comp2526 ;

public   abstract   class   AbstractClassWithMethod
{
     public   void  foo ()
     {
     }
}

ClassImplementsMethod.java

ClassImplementsMethod.java

package  ca . bcit . comp2526 ;

public   class   ClassImplementsMethod
     implements   InterfaceWithAbstractMethod
{
    @ Override
     public   void  foo ()
     {
     }

     public   static   void  main ( final   String []  argv )
     {
         final   InterfaceWithAbstractMethod  a ;
         final   ClassImplementsMethod  b ;

        a  =   new   ClassImplementsMethod ();
        b  =   new   ClassImplementsMethod ();

        a . foo ();
        b . foo ();
     }
}

ClassOverridesDefaultMethod.java

ClassOverridesDefaultMethod.java

package  ca . bcit . comp2526 ;

public   class   ClassOverridesDefaultMethod
     implements   InterfaceWithDefaultMethod
{
    @ Override
     public   void  foo ()
     {
     }

     public   static   void  main ( final   String []  argv )
     {
         final   InterfaceWithDefaultMethod  a ;
         final   ClassOverridesDefaultMethod  b ;

        a  =   new   ClassOverridesDefaultMethod ();
        b  =   new   ClassOverridesDefaultMethod ();

        a . foo ();
        b . foo ();
     }
}

ClassWithDefaultMethod.java

ClassWithDefaultMethod.java

package  ca . bcit . comp2526 ;

public   class   ClassWithDefaultMethod
     implements   InterfaceWithDefaultMethod
{

     public   static   void  main ( final   String []  argv )
     {
         final   InterfaceWithDefaultMethod  a ;
         final   ClassWithDefaultMethod  b ;

        a  =   new   ClassWithDefaultMethod ();
        b  =   new   ClassWithDefaultMethod ();

        a . foo ();
        b . foo ();
     }
}

ClassWithImplements.java

ClassWithImplements.java

package  ca . bcit . comp2526 ;

import  java . io . Serializable ;
import  java . util . List ;

public   abstract   class   ClassWithImplements
     implements   Comparable < ClassWithImplements > ,   Serializable ,   List < String > ,   Iterable < String > ,   AutoCloseable
{
}

EmptyAbstractClass.java

EmptyAbstractClass.java

package  ca . bcit . comp2526 ;

public   abstract   class   EmptyAbstractClass
{
}

EmptyClass.java

EmptyClass.java

package  ca . bcit . comp2526 ;

public   class   EmptyClass
{
}

EmptyFinalClass.java

EmptyFinalClass.java

package  ca . bcit . comp2526 ;

public   final   class   EmptyFinalClass
{
}

EmptyInterface.java

EmptyInterface.java

package  ca . bcit . comp2526 ;

public   interface   EmptyInterface
{
}

InterfaceWithAbstractMethod.java

InterfaceWithAbstractMethod.java

package  ca . bcit . comp2526 ;

public   interface   InterfaceWithAbstractMethod
{
     void  foo ();
}

InterfaceWithDefaultMethod.java

InterfaceWithDefaultMethod.java

package  ca . bcit . comp2526 ;

public   interface   InterfaceWithDefaultMethod
{
     default   void  foo ()
     {
     }
}

MHD.java

MHD.java

package  ca . bcit . comp2526 ;

import  java . util . List ;

// https://dzone.com/articles/hacking-lambda-expressions-in-java
public   class  MHD
{
     public   void  printElements ( final   List < String >  strings )
     {
        strings . forEach ( item  ->   System . out . println ( String . format ( "Item = %s" ,  item )));
     }
}

WithDouble.java

WithDouble.java

package  ca . bcit . comp2526 ;

public   class   WithDouble
{
     private   double  x  =   11.0 ;
}

WithDoubleConstant.java

WithDoubleConstant.java

package  ca . bcit . comp2526 ;

public   class   WithDoubleConstant
{
     private   static   final   double  X  =   11.0 ;
}

WithFloat.java

WithFloat.java

package  ca . bcit . comp2526 ;

public   class   WithFloat
{
     private   float  x  =   11.1f ;
}

WithFloatConstant.java

WithFloatConstant.java

package  ca . bcit . comp2526 ;

public   class   WithFloatConstant
{
     private   static   final   float  X  =   11.1f ;
}

WithInt.java

WithInt.java

package  ca . bcit . comp2526 ;

public   class   WithInt
{
     private   int  x  =   12345678 ;
}

WithIntConstant.java

WithIntConstant.java

package  ca . bcit . comp2526 ;

public   class   WithIntConstant
{
     private   static   final   int  X  =   12345678 ;
}

WithLong.java

WithLong.java

package  ca . bcit . comp2526 ;

public   class   WithLong
{
     private   long  x  =   13L ;
}

WithLongConstant.java

WithLongConstant.java

package  ca . bcit . comp2526 ;

public   class   WithLongConstant
{
     private   static   final   long  X  =   13L ;
}

WithString.java

WithString.java

package  ca . bcit . comp2526 ;

public   class   WithString
{
     private   String  x  =   "Hello, World!" ;
}

WithStringConstant.java

WithStringConstant.java

package  ca . bcit . comp2526 ;

public   class   WithStringConstant
{
     private   static   final   String  X  =   "Hello, World!" ;
}

Table of Contents.html

 
COMP-2526-HY1 - OO Programming with Java - 65955 - Lecture/Lab Combo - Assignment 3

1. Specification

2. Assignment 3

3. Classes