Prepare the pineapple filling by whisking the pineapple with its juice, sugar, cornstarch, milk, and lemon juice in a saucepan.
Cook over medium heat, stirring constantly, until the filling bubbles gently and looks like thick pudding. Remove from the heat, stir in the butter, cover the surface with plastic wrap, and cool completely.
Preheat the oven to 350°F (175°C). Grease two 8-inch cake pans and line the bottoms with parchment paper.
Whisk the flour, cornstarch, baking powder, baking soda, and salt in a medium bowl.
Beat the butter, oil, and sugar for 2–3 minutes until light. Add the eggs one at a time, then the vanilla and coconut extract.
Mix in the drained pineapple. Add half of the dry ingredients and mix on low speed just until combined. Add the coconut milk and mix gently, then add the remaining dry ingredients and stop mixing when the flour disappears. Fold in the shredded coconut.
Divide the batter between the pans. Bake for 30–35 minutes, or until a toothpick comes out clean or with a few moist crumbs.
Cool the cakes in the pans for 15 minutes, then transfer to wire racks to cool completely.
For the frosting, beat the butter until creamy. Add the cream cheese and beat until smooth. Add the powdered sugar gradually, followed by the vanilla, coconut extract, and salt. Mix just until smooth.
Place one cake layer on a serving plate. Spread a thin layer of frosting on top and pipe a border around the edge.
Spread the cooled pineapple filling inside the border. Place the second cake layer on top.
Frost the top and sides. Cover with shredded coconut and decorate with pineapple pieces if desired.
Refrigerate for 30–60 minutes before slicing.